摘要: LeetCode 169 Majority Element可以先排序,再return中位数,但估计这种方法不会被面试官认可。这里用到了Moore’s voting algorithm http://www.cs.utexas.edu/~moore/best-ideas/mjrty/example.h... 阅读全文
posted @ 2015-11-16 09:44 Walker_Lee 阅读(108) 评论(0) 推荐(0) 编辑
摘要: LeetCode 191 Number of 1 Bitshttps://en.wikipedia.org/wiki/Hamming_weightint hammingWeight(uint32_t n) { int num=0; while(n!=0) { n&=(... 阅读全文
posted @ 2015-11-16 09:16 Walker_Lee 阅读(83) 评论(0) 推荐(0) 编辑
摘要: LeetCode 235 Lowest Common Ancestor of a Binary Search Tree/** * Definition for a binary tree node. * struct TreeNode { * int val; * struct Tr... 阅读全文
posted @ 2015-11-16 09:07 Walker_Lee 阅读(147) 评论(0) 推荐(0) 编辑