-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathabc.java
More file actions
28 lines (27 loc) · 742 Bytes
/
abc.java
File metadata and controls
28 lines (27 loc) · 742 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
public class abc {
public static int[] twoSum(int[] nums, int target) {
int i = 1, a = 0;
int ans[] = new int[2];
while (a < nums.length) {
if (nums[a] + nums[i] == target) {
ans[0] = a;
ans[1] = i;
return ans;
}
i++;
if (i == nums.length) {
a = a + 1;
if (a < nums.length - 1)
i = a + 1;
}
}
return null;
}
public static void main(String[] args) {
int nums[] = { 3, 2, 3 };
twoSum(nums, 8);
for (int el : twoSum(nums, 8)) {
System.out.println(el);
}
}
}