mirror of
https://github.com/arkorty/LeetCode.git
synced 2026-03-17 16:51:46 +00:00
11 lines
313 B
Java
11 lines
313 B
Java
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 };
|
|
}
|
|
}
|