이분탐색 정리
2019 카카오 개발자 겨울 인턴십
def solution(s):
# 젤 많은 갯수 부터 써주면 될듯
# 계수 정렬 사용
answer = []
list_ = [0 for x in range(100001)]
tmp_str2int = ""
for i in s:
try:
int_checker = int(i)
tmp_str2int += i
except:
if tmp_str2int:
list_[int(tmp_str2int)] += 1
tmp_str2int = ""
continue
temp_answer = []
for i in range(len(list_)):
if list_[i] > 0:
temp_answer.append([i,list_[i]]) # 숫자, 그 숫자 cnt
temp_answer.sort(key = lambda x : x[1], reverse = True)
for i in range(len(temp_answer)):
answer.append(temp_answer[i][0])
return answer
계수 정렬을 사용하여 O(n)이지만, 뒤에 sort를 썼기에 O(nlogn)에 통과하였다.