摘要: Q:Suppose a sorted array is rotated at some pivot unknown to you beforehand.(i.e.,0 1 2 4 5 6 7might become4 5 6 7 0 1 2).You are given a target value to search. If found in the array return its index, otherwise return -1.You may assume no duplicate exists in the array.A: 递归+二分查找。 int bisearch(in... 阅读全文
posted @ 2013-06-17 21:33 summer_zhou 阅读(120) 评论(0) 推荐(0) 编辑
摘要: Q:Follow up for problem "Populating Next Right Pointers in Each Node".What if the given tree could be any binary tree? Would your previous solution still work?Note:You may only use constant extra space.For example,Given the following binary tree, 1 / \ 2 3 / \ \ 4 ... 阅读全文
posted @ 2013-06-17 21:08 summer_zhou 阅读(202) 评论(0) 推荐(0) 编辑
摘要: Q:Given a binary tree struct TreeLinkNode { TreeLinkNode *left; TreeLinkNode *right; TreeLinkNode *next; }Populate each next pointer to point to its next right node. If there is no next right node, the next pointer should be set toNULL.Initially, all next pointers are set toNULL... 阅读全文
posted @ 2013-06-17 16:04 summer_zhou 阅读(189) 评论(0) 推荐(0) 编辑