Skip to content

Commit 90b51aa

Browse files
author
jinvicky
committed
lint fix
1 parent 1fac60a commit 90b51aa

File tree

1 file changed

+7
-3
lines changed

1 file changed

+7
-3
lines changed

two-sum/jinvicky.java

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,30 +5,34 @@
55
* 본래 brute force로 이중 for문으로 풀었다가 map으로 최적화.
66
*/
77
class Solution {
8+
89
/**
910
* brute force 풀이
1011
*/
1112
// public int[] twoSumByBruteForce(int[] nums, int target) {
1213
// for (int i = 0; i < nums.length; i++) {
13-
// for (int j = i+1; j < nums.length; j++) {
14+
// for (int j = i + 1; j < nums.length; j++) {
1415
// if (nums[i] + nums[j] == target) {
15-
// return new int[] { i, j };
16+
// return new int[]{i, j};
1617
// }
1718
// }
1819
// }
1920
// return new int[2];
2021
// }
2122
public int[] twoSum(int[] nums, int target) {
2223
Map<Integer, Integer> numberMap = new HashMap<>();
24+
2325
for (int i = 0; i < nums.length; i++) {
2426
int required = target - nums[i];
2527
Integer index = numberMap.get(required);
2628

2729
if (index != null) {
2830
return new int[]{index, i};
2931
}
32+
3033
numberMap.put(nums[i], i);
3134
}
35+
3236
return new int[2];
3337
}
34-
}
38+
}

0 commit comments

Comments
 (0)