classSolution{publicintmaxArea(int[] height){int i =0, j = height.length -1;int max =0;while(i < j){int h =Math.min(height[i], height[j]);int w = j - i;
max =Math.max(max, h * w);if(height[i]<= height[j]){
i++;}else{
j--;}}return max;}}
classSolution{publicintminSubArrayLen(int target,int[] nums){//假设滑动窗口[l...r]int l =0, r =-1;int res = nums.length +1;int sum =0;while(l < nums.length){if(r +1< nums.length && sum < target){
sum += nums[++r];}else{
sum -= nums[l++];}if(sum >= target){
res =Math.min(res, r - l +1);}}return res == nums.length +1?0: res;}}
classSolution{publicintlengthOfLongestSubstring(String s){//假设滑动窗口[l...r]为无重复子串int l =0, r =-1;int res =0;//int数组实现字符频率计数int[] freq =newint[256];while(l < s.length()){if(r +1< s.length()&& freq[s.charAt(r+1)]==0){
freq[s.charAt(++r)]++;}else{
freq[s.charAt(l++)]--;}
res =Math.max(res, r - l +1);}return res;}}
classSolution{publicList<Integer>findAnagrams(String s,String p){int n = s.length(), m = p.length();List<Integer> res =newArrayList<>();if(n < m)return res;int[] pCnt =newint[26];int[] sCnt =newint[26];for(int i =0; i < m; i++){
pCnt[p.charAt(i)-'a']++;
sCnt[s.charAt(i)-'a']++;}if(Arrays.equals(sCnt, pCnt)){
res.add(0);}for(int i = m; i < n; i++){
sCnt[s.charAt(i - m)-'a']--;
sCnt[s.charAt(i)-'a']++;if(Arrays.equals(sCnt, pCnt)){
res.add(i - m +1);}}return res;}}
常规题283. 移动零27. 移除元素26. 删除有序数组中的重复项80. 删除有序数组中的重复项 IIclass Solution { public int removeDuplicates(int[] nums) { int n = nums.length; if (n < 2) { return n; } int slow = 2, fast = 2; while(fas