摘要: class Solution { public ListNode reverseBetween(ListNode head, int m, int n) { ListNode pre=new ListNode(0); pre.next=head; ListNode p=pre; for(int i=0;i0) ... 阅读全文
posted @ 2017-09-28 13:23 Weiyu Wang 阅读(97) 评论(0) 推荐(0) 编辑
摘要: public class Solution { public int numDecodings(String s) { if(s.length()==0) return 0; int[] dp=new int[s.length()+1]; dp[0]=1; for(int i=0;i'0'&&s.ch... 阅读全文
posted @ 2017-09-28 13:14 Weiyu Wang 阅读(119) 评论(0) 推荐(0) 编辑
摘要: public class Solution { public List> subsetsWithDup(int[] nums) { List> res=new ArrayList>(); Arrays.sort(nums); subsetsWithDup(0, new ArrayList(), res, nums); ret... 阅读全文
posted @ 2017-09-28 12:39 Weiyu Wang 阅读(124) 评论(0) 推荐(0) 编辑
摘要: 1st bit: 0->1->1->0->0->1->1->0 2nd bit: 0->0->1->1->1->1->0->0 3rd bit: 0->0->0->0->1->1->1->1 阅读全文
posted @ 2017-09-28 12:09 Weiyu Wang 阅读(140) 评论(0) 推荐(0) 编辑
摘要: class Solution { public boolean isScramble(String s1, String s2) { if(s1.length()==0||s1.equals(s2)) return true; int[] cnt=new int[128]; for(int i=0;i<s1.leng... 阅读全文
posted @ 2017-09-28 06:56 Weiyu Wang 阅读(105) 评论(0) 推荐(0) 编辑
摘要: class Solution { public ListNode partition(ListNode head, int x) { ListNode l1=new ListNode(0); ListNode l2=new ListNode(0); ListNode pre=new ListNode(0); pre.next... 阅读全文
posted @ 2017-09-28 06:32 Weiyu Wang 阅读(98) 评论(0) 推荐(0) 编辑
摘要: 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 阅读(124) 评论(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 阅读(100) 评论(0) 推荐(0) 编辑