题目如图
代码如下
class Solution {
public int[] twoSum(int[] nums, int target) {
int arr[] = new int[2];
int n = nums.length;
for(int i =0;i < n;i++){
for(int j = 1;j < n;j++){
if(target == nums[i] + nums[j]){
arr[0] = i;
arr[1] = j;
return arr;
}
}
}
return arr;
}
}