mirror of
https://github.com/arkorty/LeetCode.git
synced 2026-03-18 00:57:17 +00:00
Initial commit
This commit is contained in:
10
Easy/two-sum/Solution.java
Normal file
10
Easy/two-sum/Solution.java
Normal file
@@ -0,0 +1,10 @@
|
||||
class Solution {
|
||||
public int[] twoSum(int[] nums, int target) {
|
||||
for (int i = 0; i < nums.length - 1; i++)
|
||||
for (int j = i + 1; j < nums.length; j++)
|
||||
if (target - nums[i] == nums[j])
|
||||
return new int[] { i, j };
|
||||
|
||||
return new int[] { -1, -1 };
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user