摘要: 自己的做法超时了。主要是每次生成一个数据,保存到list中,然后对List重新排序。排序太耗费时间记录下讨论组里的写法public int NthUglyNumber(int n) { int[] ugly = new int[n]; ugly[0] = 1; int i... 阅读全文
posted @ 2015-08-20 10:30 darksied 阅读(138) 评论(0) 推荐(0) 编辑
摘要: public bool IsUgly(int num) { if(num1) { if(num%2==0) { num=num/2; } else if(num%3==0) { num=num/3; } else if(n... 阅读全文
posted @ 2015-08-19 17:50 darksied 阅读(139) 评论(0) 推荐(0) 编辑
摘要: 正常写法bool HasPathSum(TreeNode root, int sum) { bool ret=false; if(root==null)return false; if(root.left==null&&root.right==null) return root.val=... 阅读全文
posted @ 2015-08-14 10:01 darksied 阅读(129) 评论(0) 推荐(0) 编辑
摘要: 大都是自定义了Interval的比较方法。突发奇想int [] arr=new int[intervals.Count*2]; for(int i=0;i list=new List(); int s=0;//int e=1; int count=0; for(int i=0;... 阅读全文
posted @ 2015-08-12 12:03 darksied 阅读(163) 评论(0) 推荐(0) 编辑
摘要: static List nums = new List(); public static bool IsHappy(int n) { int newint = 0; while (n != 0) { ... 阅读全文
posted @ 2015-08-07 18:21 darksied 阅读(221) 评论(0) 推荐(0) 编辑