上一页 1 ··· 4 5 6 7 8 9 10 11 12 ··· 22 下一页
摘要: class Solution { public void recoverTree(TreeNode root) { TreeNode cur=root,pre=null,node1=null,node2=null, p=null; while(cur!=null) { if(cur.left!=null) ... 阅读全文
posted @ 2017-09-29 10:01 Weiyu Wang 阅读(102) 评论(0) 推荐(0) 编辑
摘要: public class Solution { public boolean isValidBST(TreeNode root) { Stack stack=new Stack(); TreeNode cur=null; while(root!=null||!stack.isEmpty()) { ... 阅读全文
posted @ 2017-09-29 06:32 Weiyu Wang 阅读(137) 评论(0) 推荐(0) 编辑
摘要: class Solution { public boolean isInterleave(String s1, String s2, String s3) { if(s1.length()+s2.length()!=s3.length()) return false; boolean [][] dp=new boolean[s1.l... 阅读全文
posted @ 2017-09-29 06:20 Weiyu Wang 阅读(111) 评论(0) 推荐(0) 编辑
摘要: public class Solution { public int numTrees(int n) { int[] dp=new int[n+1]; dp[0]=1; dp[1]=1; for(int i=2;i<=n;i++) for(int j=1;j<=i;j++) ... 阅读全文
posted @ 2017-09-29 02:30 Weiyu Wang 阅读(125) 评论(0) 推荐(0) 编辑
摘要: class Solution { public List generateTrees(int n) { if(n==0) return new ArrayList(); return generateTrees(1, n); } private List generateTrees(int i, int j) { ... 阅读全文
posted @ 2017-09-29 02:19 Weiyu Wang 阅读(140) 评论(0) 推荐(0) 编辑
摘要: public class Solution { public List inorderTraversal(TreeNode root) { List res=new ArrayList(); Stack stack=new Stack(); while(root!=null||!stack.isEmpty()) { ... 阅读全文
posted @ 2017-09-29 02:01 Weiyu Wang 阅读(160) 评论(0) 推荐(0) 编辑
摘要: class Solution { public List restoreIpAddresses(String s) { List res=new ArrayList(); restoreIpAddresses("", 0, 0, s, res); return res; } private void restoreIpAdd... 阅读全文
posted @ 2017-09-29 01:52 Weiyu Wang 阅读(172) 评论(0) 推荐(0) 编辑
摘要: 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) 编辑
上一页 1 ··· 4 5 6 7 8 9 10 11 12 ··· 22 下一页