随笔分类 -  每日一刷

算法刷题,主要是java,一部分c++,c
摘要:public void rotate(int[] nums, int k) { int n = nums.length; int [] tmp = new int [k]; int j=0; int i =0; k... 阅读全文
posted @ 2015-06-30 15:59 puckpuck 阅读(179) 评论(0) 推荐(0)
摘要:public class Solution { public boolean isHappy(int n) { Set set = new HashSet(); while(n != 1 && !set.contains(n)){ set.add(n); i... 阅读全文
posted @ 2015-06-30 09:57 puckpuck 阅读(146) 评论(0) 推荐(0)
摘要:Invert a binary tree. 4 / \ 2 7 / \ / \1 3 6 9to 4 / \ 7 2 / \ / \9 6 3 1Trivia:This problem was inspired bythis... 阅读全文
posted @ 2015-06-25 19:33 puckpuck 阅读(103) 评论(0) 推荐(0)
摘要:这个鸟玩意用了迭代,其实不太好浪费空间,数据多了还容易死,有人用stack还没研究 昨天代码有错误,num在运算后没有清零,有几个标点错误,在程序中红体,但是昨天date去了这个还是没有测,我肉眼debug的这个是600mm的还没看明白https://leetcode.com/discuss/394... 阅读全文
posted @ 2015-06-09 15:44 puckpuck 阅读(780) 评论(0) 推荐(0)
摘要:Find the total area covered by tworectilinearrectangles in a2Dplane.Each rectangle is defined by its bottom left corner and top right corner as shown ... 阅读全文
posted @ 2015-06-08 22:07 puckpuck 阅读(388) 评论(0) 推荐(0)
摘要:public class Solution { public int singleNumber(int[] nums) { int ret = nums[0]; for (int i = 1; i < nums.length; i++) { ret ^= nums[i]; ... 阅读全文
posted @ 2015-06-08 16:23 puckpuck 阅读(203) 评论(0) 推荐(0)
摘要:public class Solution { public String addBinary(String a, String b) { int i = a.length()-1; int j = b.length()-1; int n = j>i?j:i; int su... 阅读全文
posted @ 2015-06-08 13:23 puckpuck 阅读(259) 评论(0) 推荐(0)