[Leetcode]--Two Sum

[Leetcode]--Two Sum
public class Solution {
    public int[] twoSum(int[] numbers, int target) {
        // IMPORTANT: Please reset any member data you declared, as
        // the same Solution instance will be reused for each test case.
        
        int[] results = new int[2];
         
         for(int i = 0; i < numbers.length - 1; i++){
             for(int j = i + 1; j < numbers.length; j++){
                 if(numbers[i] + numbers[j] == target){
                     results[0] = i + 1;
                     results[1] = j + 1;
                     return results;
                 }
             }
         }
         return results;
        
    }
}
[Leetcode]--Two Sum

[Leetcode]--Two Sum

上一篇:cacheAsBitmap位图缓存


下一篇:cocos2dx 屏幕适配