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 29f66f7 commit 1f42136Copy full SHA for 1f42136
two-sum/jinhyungrhee.java
@@ -0,0 +1,17 @@
1
+class Solution {
2
+
3
+ // Method1. brute-force => O(N^2)
4
+ public int[] twoSum(int[] nums, int target) {
5
+ int size = nums.length;
6
+ int[] answer = new int[2];
7
+ for (int i = 0; i < size; i++) {
8
+ for (int j = i + 1; j < size; j++) {
9
+ if (nums[i] + nums[j] == target) {
10
+ answer[0] = i;
11
+ answer[1] = j;
12
+ }
13
14
15
+ return answer;
16
17
+}
0 commit comments