摘要: public class Solution { public int numTrees(int n) { //可以采用递归方式,也可以采用线性规划,进行优化 List results=new ArrayList(); for(int i=0;i<=n;i++) { if(i==0||i==1) ... 阅读全文
posted @ 2016-04-03 15:37 阿怪123 阅读(118) 评论(0) 推荐(0)
摘要: /** * Definition for a binary tree node. * public class TreeNode { * int val; * TreeNode left; * TreeNode right; * TreeNode(int x) { val = x; } * } */ public class Solution { ... 阅读全文
posted @ 2016-04-03 15:16 阿怪123 阅读(92) 评论(0) 推荐(0)
摘要: /** * Definition for binary tree with next pointer. * public class TreeLinkNode { * int val; * TreeLinkNode left, right, next; * TreeLinkNode(int x) { val = x; } * } */ public clas... 阅读全文
posted @ 2016-04-03 14:41 阿怪123 阅读(111) 评论(0) 推荐(0)
摘要: /** * Definition for binary tree with next pointer. * public class TreeLinkNode { * int val; * TreeLinkNode left, right, next; * TreeLinkNode(int x) { val = x; } * } */ public clas... 阅读全文
posted @ 2016-04-03 14:39 阿怪123 阅读(102) 评论(0) 推荐(0)
摘要: /** * Definition for a binary tree node. * public class TreeNode { * int val; * TreeNode left; * TreeNode right; * TreeNode(int x) { val = x; } * } */ public class Solution { ... 阅读全文
posted @ 2016-04-03 11:44 阿怪123 阅读(110) 评论(0) 推荐(0)
摘要: public class Solution { public int majorityElement(int[] nums) { Map mp=new HashMap(); int len=nums.length; int res=0; if(len==1) return nums[0]; ... 阅读全文
posted @ 2016-04-03 11:37 阿怪123 阅读(125) 评论(0) 推荐(0)
摘要: public class Solution { public int titleToNumber(String s) { int len=s.length(); int res=0; for(int i=0;i<len;i++) { res=res*26; res+=((s.c... 阅读全文
posted @ 2016-04-03 11:30 阿怪123 阅读(135) 评论(0) 推荐(0)
摘要: public class Solution { // you need treat n as an unsigned value public int reverseBits(int n) { int res=0; for(int i=0;i>>((i-15)*2-1)|res); } return res; ... 阅读全文
posted @ 2016-04-03 11:25 阿怪123 阅读(87) 评论(0) 推荐(0)
摘要: public class Solution { public boolean isHappy(int n) { boolean res=false; Map mp=new HashMap(); int temp=n; while(true) { int sum=0; ... 阅读全文
posted @ 2016-04-03 10:28 阿怪123 阅读(79) 评论(0) 推荐(0)
摘要: public class Solution { public int rob(int[] nums) { int len=nums.length; if(len==0) return 0; int[] money=new int[len]; for(int i=0;i=(mo2+num... 阅读全文
posted @ 2016-04-03 10:16 阿怪123 阅读(107) 评论(0) 推荐(0)