刷题
文章平均质量分 61
fredlumm
这个作者很懒,什么都没留下…
展开
-
Count 1 in Binary
Count how many 1 in binary representation of a 32-bit integer. Example Given 32, return 1 Given 5, return 2 Given 1023, return 9 Challenge If the integer is n bits with m 1 bits. Can you do原创 2016-01-18 03:25:16 · 214 阅读 · 0 评论 -
Partition Array by Odd and Even
Partition an integers array into odd number first and even number second. Example Given [1, 2, 3, 4], return [1, 3, 2, 4] Challenge Do it in-place. 非常典型的two pointer: 一个左指针,一个右指针, 当left 指原创 2016-01-18 03:51:28 · 210 阅读 · 0 评论 -
Subtree
You have two every large binary trees: T1, with millions of nodes, and T2, with hundreds of nodes. Create an algorithm to decide if T2 is a subtree of T1. 1. 利用BFS 搜索到第一个node 与T2 的root相同,然后进行判断这两原创 2016-01-18 04:33:40 · 292 阅读 · 0 评论 -
find Minimum and Maximum in Rotated Sorted Arrray
int findMin(vector& nums) { int start = 0; int end = nums.size() - 1; while(start + 1 < end){ int mid = start + (end - start)/2; if(nums[mid] < nums[end原创 2016-01-26 05:00:42 · 231 阅读 · 0 评论