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 90b51aa commit 4f3d5a2Copy full SHA for 4f3d5a2
two-sum/jinvicky.java
@@ -6,19 +6,17 @@
6
*/
7
class Solution {
8
9
- /**
10
- * brute force 풀이
11
- */
12
-// public int[] twoSumByBruteForce(int[] nums, int target) {
13
-// for (int i = 0; i < nums.length; i++) {
14
-// for (int j = i + 1; j < nums.length; j++) {
15
-// if (nums[i] + nums[j] == target) {
16
-// return new int[]{i, j};
17
-// }
18
19
20
-// return new int[2];
21
+ public int[] twoSumByBruteForce(int[] nums, int target) {
+ for (int i = 0; i < nums.length; i++) {
+ for (int j = i + 1; j < nums.length; j++) {
+ if (nums[i] + nums[j] == target) {
+ return new int[]{i, j};
+ }
+ return new int[2];
+
22
public int[] twoSum(int[] nums, int target) {
23
Map<Integer, Integer> numberMap = new HashMap<>();
24
0 commit comments