2171 217, Contains Duplicate 1. 브루트 포스 class Solution: def containsDuplicate(self, nums: List[int]) -> bool: """brute force Time Complexity: O(n^2) Space Complexity: O(1) Returns: Time Limit Exceeded """ _len = len(nums) for i in range(_len-1): temp = nums[i] for j in range(i+1, _len): if temp == nums[j]: return True return False 2. 정렬 class Solution: def containsDuplicate(self, nums: List[int]) -> bool: """sort 파이썬의 내장함수 .. 2024. 2. 19. 이전 1 다음