class Solution {
// 时间复杂度:O(n)
// 空间复杂度:O(1)
public int[] twoSum(int[] nums, int target){if(nums == null || nums.length ==0)return new int[0];
int left =0;
int right = nums.length - 1;while(left < right){
int sum= nums[left] + nums[right];if(sum == target){return new int[]{left, right};}elseif(sum < target){
left++;}else{
right--;}}return new int[0];}}
class Solution {
public static List<List<Integer>> threeSum(int[] nums){
List<List<Integer>> ans = new ArrayList();
int lg = nums.length;
Arrays.sort(nums);
for(int i =0; i < lg; i++){
if(nums[i]>0){break;}
if(i >0&& nums[i-1]== nums[i]){continue;}
int left = i+1;
int right = lg-1;
while(left < right){
if(nums[i] + nums[left] + nums[right]==0){
List<Integer> list = new ArrayList<>();
list.add(nums[i]);
list.add(nums[left]);
list.add(nums[right]);
ans.add(list);
while(left < right && nums[left]== nums[left+1]){
left++;}
left++;}else if(nums[i] + nums[left] + nums[right]>0){
right--;}else{
left++;}}}return ans;}}
class Solution {
public int minSubArrayLen(int s, int[] nums){
int n = nums.length;if(n ==0){return0;}
int ans = Integer.MAX_VALUE;
int start =0, end =0;
int sum=0;while(end < n){sum+= nums[end];while(sum >= s){
ans = Math.min(ans, end - start + 1);sum -= nums[start];
start++;}
end++;}return ans == Integer.MAX_VALUE ? 0: ans;}}
class Solution { // 时间复杂度:O(n) // 空间复杂度:O(1) public int[] twoSum(int[] nums, int target) { if (nums == null || nums.length == 0) return new int[0]; int left = 0; int right = nums.length - 1; while (left < ri.