hacking or software engineering skills/programmers (1) 썸네일형 리스트형 [programmers - python] 체육복 (greedy) 첫번째 시도 한문제 맞춤… def solution(n, lost, reserve): lost_new = sorted(set(lost) - set(reserve),reverse = True) reserve_new = sorted(set(reserve) - set(lost),reverse=True) given = [] given_flag = False while reserve_new: while lost_new: lo = lost_new[-1] temp = reserve_new[-1] if temp - 1 == lo or temp + 1 == lo: given.append(reserve_new.pop()) lost_new.pop() given_flag = True break if not given_flag:.. 이전 1 다음