2数之和

版权声明:本文为博主原创文章,未经博主允许不得转载。 https://blog.csdn.net/qq_39598417/article/details/88915637

class Solution {
    public int[] twoSum(int[] nums, int target) {
        int[] ss= new int [2];
        for(int i = 0 ; i < nums.length ; i++ ){
            for(int j = i + 1 ; j < nums.length ; j++ ){
                if(target == (nums[i] + nums[j])){
                   ss[0] = i; 
                   ss[1] = j;
                }
            }
        }
        return ss;
    }
}

猜你喜欢

转载自blog.csdn.net/qq_39598417/article/details/88915637