题目:
分析:
思路:
代码:
- class Solution {
- public int[] twoSum(int[] price, int target) {
- int left = 0;
- int right = price.length-1;
- while(left
- if(price[left] + price[right] > target) right--;
- else if(price[left] + price[right] < target) left++;
- else return new int[]{price[left],price[right]};
- }
- return null;
- }
- }