LeetCode1。二つの数字(JAVAの実現)

トピック:

コード:

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

 

公開された31元の記事 ウォンの賞賛1 ビュー1254

おすすめ

転載: blog.csdn.net/qq_45824565/article/details/104593127
おすすめ