-
폰켓몬프로그래밍/알고리즘 2021. 3. 25. 22:14
나의 풀이
def solution(nums): answer = 0 length = len(nums) // 2 nums = list(set(nums)) for value in nums: if answer < length: answer += 1 return answer
다른 사람 풀이 1
def solution(ls): return min(len(ls)/2, len(set(ls)))
min 함수에 인자가 두개가 들어오면 두개 중에 낮은 min값을 리턴한다.
728x90반응형LIST'프로그래밍 > 알고리즘' 카테고리의 다른 글
3진법 뒤집기 (0) 2021.03.27 신규 아이디 추천 (0) 2021.03.27 내적 (0) 2021.03.25 수박수박수박수박수박수? (0) 2021.03.25 문자열 내림차순으로 배치하기 (0) 2021.03.25