随笔分类 -  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... 阅读全文
posted @ 2017-09-28 06:24 Weiyu Wang 阅读(129) 评论(0) 推荐(0)
摘要: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<... 阅读全文
posted @ 2017-09-28 01:51 Weiyu Wang 阅读(106) 评论(0) 推荐(0)
摘要:public class Solution { public int removeDuplicates(int[] nums) { if(nums.length nums[i-2]) nums[i++] = n; return i; } 阅读全文
posted @ 2017-09-27 05:30 Weiyu Wang 阅读(110) 评论(0) 推荐(0)
摘要: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--; ... 阅读全文
posted @ 2017-09-27 04:38 Weiyu Wang 阅读(128) 评论(0) 推荐(0)
摘要: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) ... 阅读全文
posted @ 2017-09-24 13:15 Weiyu Wang 阅读(94) 评论(0) 推荐(0)
摘要: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++) { ... 阅读全文
posted @ 2017-09-23 11:50 Weiyu Wang 阅读(142) 评论(0) 推荐(0)
摘要: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; ... 阅读全文
posted @ 2017-09-23 07:18 Weiyu Wang 阅读(139) 评论(0) 推荐(0)
摘要: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... 阅读全文
posted @ 2017-09-23 01:23 Weiyu Wang 阅读(126) 评论(0) 推荐(0)
摘要: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++) { ... 阅读全文
posted @ 2017-09-22 12:55 Weiyu Wang 阅读(122) 评论(0) 推荐(0)
摘要:class Solution { public List> threeSum(int[] nums) { List> ret=new ArrayList>(); Arrays.sort(nums); for(int i=0;i0) r--; else ... 阅读全文
posted @ 2017-09-22 12:32 Weiyu Wang 阅读(112) 评论(0) 推荐(0)
摘要: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... 阅读全文
posted @ 2017-09-22 11:23 Weiyu Wang 阅读(137) 评论(0) 推荐(0)
摘要: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... 阅读全文
posted @ 2017-09-21 05:52 Weiyu Wang 阅读(112) 评论(0) 推荐(0)