We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent 9508bce commit 319db1eCopy full SHA for 319db1e
two-sum/ohgyulim.java
@@ -1,6 +1,12 @@
1
import java.util.*;
2
3
class Solution {
4
+/* 시간 복잡도: O(N), nums.length를 n이라고 할 때, 시간 복잡도는 O(N)
5
+ * - for 루프: O(N)
6
+ * - HashMap 연산 (containsKey, put): 평균 O(1)
7
+ *
8
+ * 공간 복잡도: O(N), HashMap에 최대 n개의 요소를 저장할 수 있음
9
+ */
10
public int[] twoSum(int[] nums, int target) {
11
Map<Integer, Integer> numToIndex = new HashMap<>();
12
for (int i = 0; i < nums.length; i++) {
0 commit comments