Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 11 additions & 0 deletions contains-duplicate/njngwn.py

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🏷️ 알고리즘 패턴 분석

  • 패턴: Sorting
  • 설명: 이 코드는 배열을 정렬한 후 인접한 값들을 비교하여 중복을 찾는 방식으로, 정렬 알고리즘이 핵심 패턴입니다.

📊 시간/공간 복잡도 분석

유저 분석 실제 분석 결과
Time O(nlogn) O(n log n)
Space O(1) O(1)

피드백: 배열을 정렬하는 데 O(n log n)의 시간 복잡도가 필요하며, 이후 인접 원소 비교는 O(n)입니다. 추가 공간은 필요하지 않습니다.

개선 제안: 현재 구현이 적절해 보입니다.

Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
class Solution:
# Time Complexity: O(nlogn), n: len(nums)
# Space Complexity: O(1)
def containsDuplicate(self, nums: List[int]) -> bool:
nums.sort() # O(nlogn)

for i in range(len(nums)):
if i > 0 and nums[i] == nums[i - 1]:
return True

return False
11 changes: 11 additions & 0 deletions two-sum/njngwn.py

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🏷️ 알고리즘 패턴 분석

  • 패턴: Sorting
  • 설명: 이 코드는 배열을 정렬한 후 인접한 값들을 비교하여 중복을 찾는 방식으로, 정렬 알고리즘을 활용하는 패턴입니다.

📊 시간/공간 복잡도 분석

유저 분석 실제 분석 결과
Time O(nlogn) O(n log n)
Space O(1) O(1)

피드백: 배열을 정렬하는 데 O(n log n)의 시간 복잡도가 필요하며, 이후 인접 원소 비교는 O(n)입니다. 추가 공간은 필요하지 않습니다.

개선 제안: 현재 구현이 적절해 보입니다.

Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
class Solution:
# Time Complexity: O(nlogn), n: len(nums)
# Space Complexity: O(1)
def containsDuplicate(self, nums: List[int]) -> bool:
nums.sort() # O(nlogn)

for i in range(len(nums)):
if i > 0 and nums[i] == nums[i - 1]:
return True

return False
Loading