Skip to content
Closed
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
2 changes: 1 addition & 1 deletion 3sum/lhc0506.js
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.

🏷️ 알고리즘 패턴 분석

  • 패턴: Two Pointers
  • 설명: 이 코드는 정렬된 배열에서 두 포인터를 활용하여 3개의 수의 합이 0이 되는 조합을 찾는 방식으로, Two Pointers 패턴에 속합니다. 효율적인 탐색을 위해 중복 제거와 정렬을 활용합니다.

📊 시간/공간 복잡도 분석

복잡도
Time O(n^2)
Space O(n)

피드백: 이 구현은 이중 반복문과 해시셋을 사용하여 중복을 방지하며, 시간 복잡도는 두 반복문이 각각 O(n)이고 해시셋 연산이 평균 O(1)이기 때문에 O(n^2)입니다. 공간은 해시셋과 결과 저장에 O(n)입니다.

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

💡 풀이에 시간/공간 복잡도를 주석으로 남겨보세요!

Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
* @return {number[][]}
*/
var threeSum = function(nums) {
const result = [];
const result = []; const seen = new Set();
const numsMap = {};

nums.forEach((num, index) => {
Expand Down
2 changes: 1 addition & 1 deletion 3sum/tedkimdev.go
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.

🏷️ 알고리즘 패턴 분석

  • 패턴: Two Pointers
  • 설명: 이 코드는 정렬된 배열에서 두 포인터를 활용하여 3개의 수의 합이 0이 되는 조합을 찾는 방식으로, 효율적인 탐색을 위해 Two Pointers 패턴을 사용합니다.

📊 시간/공간 복잡도 분석

복잡도
Time O(n^2)
Space O(n)

피드백: 이 구현은 이중 반복문과 해시셋을 사용하여 중복을 방지하며, 시간 복잡도는 두 반복문이 각각 O(n)이고 해시셋 연산이 평균 O(1)이기 때문에 O(n^2)입니다. 공간은 해시셋과 결과 저장에 O(n)입니다.

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

💡 풀이에 시간/공간 복잡도를 주석으로 남겨보세요!

Original file line number Diff line number Diff line change
Expand Up @@ -48,5 +48,5 @@ func threeSum(nums []int) [][]int {
filteredResult = append(filteredResult, k[0:len(k)])
}

return result.keys()
return filteredResult
}
Loading