时间复杂度为 O(N^2) @param nums @param target @return
(int[] nums,int target)
| 19 | * @return |
| 20 | */ |
| 21 | public int[] getTwo1(int[] nums,int target){ |
| 22 | int[] result = null; |
| 23 | |
| 24 | for (int i= 0 ;i<nums.length ;i++){ |
| 25 | int a = nums[i] ; |
| 26 | for (int j = nums.length -1 ;j >=0 ;j--){ |
| 27 | int b = nums[j] ; |
| 28 | |
| 29 | if (i != j && (a + b) == target) { |
| 30 | result = new int[]{i,j} ; |
| 31 | } |
| 32 | } |
| 33 | } |
| 34 | return result ; |
| 35 | } |
| 36 | |
| 37 | |
| 38 | /** |