随笔分类 - Slide Window
摘要:class Solution { public int maximalRectangle(char[][] matrix) { if(matrix.length==0||matrix[0].length==0) return 0; int[] heights=new int[matrix[0].length]; in...
阅读全文
摘要:class Solution { public int largestRectangleArea(int[] heights) { Stack stack=new Stack(); int maxArea=0; for(int i=0;i<=heights.length;i++) { int h=i<...
阅读全文
摘要:public class Solution { public int removeDuplicates(int[] nums) { if(nums.length nums[i-2]) nums[i++] = n; return i; }
阅读全文
摘要:class Solution { public String minWindow(String s, String t) { boolean[] chs=new boolean[128]; int[] cnt=new int[128]; for(int i=0;i0&&r0) count--; ...
阅读全文
摘要:class Solution { public int trap(int[] height) { int sum=0; int l=0; int r=height.length-1; int left=0; int right=0; while(lleft) ...
阅读全文
摘要:class Solution { public int longestValidParentheses(String s) { int left=-1; Stack stack=new Stack(); int ret=0; for(int i=0;i<s.length();i++) { ...
阅读全文
摘要:class Solution { public List findSubstring(String s, String[] words) { List ret=new ArrayList(); if(words.length==0||words[0].length()==0||s.length()==0) return ret; ...
阅读全文
摘要:public class Solution { public List> fourSum(int[] nums, int target) { List> ret=new ArrayList>(); Arrays.sort(nums); for(int i=0;i<nums.length;i++) i...
阅读全文
摘要:class Solution { public int threeSumClosest(int[] nums, int target) { Arrays.sort(nums); int ret=nums[0]+nums[1]+nums[2]; for(int i=0;i<nums.length;i++) { ...
阅读全文
摘要:class Solution { public List> threeSum(int[] nums) { List> ret=new ArrayList>(); Arrays.sort(nums); for(int i=0;i0) r--; else ...
阅读全文
摘要:class Solution { public int maxArea(int[] height) { int maxArea=0; int i=0; int j=height.length-1; while(i<j) { maxArea=Math.max(maxArea,Math.m...
阅读全文
摘要:class Solution { public int lengthOfLongestSubstring(String s) { Map map=new HashMap(); int maxlen=0; for(int j=0,i=0;i<s.length();i++) { char c=s.char...
阅读全文

浙公网安备 33010602011771号