java代码如下
public class Solution {
public int[] twoSum(int[] nums, int target) {
int len = nums.length;
int index1 = 0, index2 = 0;
int reduction;
for (int i = 0; i < len; i++)
{
reduction = target - nums[i];
for (int j = i + 1; j < len; j++)
{
if(reduction == nums[j])
{
index1 = i + 1;
index2 = j + 1;
break;
}
}
}
int[] result = {index1, index2};
return result;
}
}