There was an error while loading. Please reload this page.
1 parent d125593 commit 94e5b79Copy full SHA for 94e5b79
0001-two-sum/0001-two-sum.java
@@ -0,0 +1,13 @@
1
+class Solution {
2
+ public int[] twoSum(int[] nums, int target) {
3
+ for(int i = 0; i < nums.length; i++) {
4
+ for(int j = i + 1; j < nums.length; j++) {
5
+ if(nums[i] + nums[j] == target) {
6
+ return new int[] {i, j};
7
+ }
8
9
10
+ // Add this line to avoid compilation error
11
+ return new int[] {}; // or throw new IllegalArgumentException("No solution found");
12
13
+}
0 commit comments