摘要: Invert a binary tree. Example 1 1 / \ / \ 2 3 => 3 2 / \ 4 4 Challenge Do it in recursion is acceptable, can you do it without recursion? 1. 递归 /** * 阅读全文
posted @ 2016-02-26 03:22 哥布林工程师 阅读(155) 评论(0) 推荐(0) 编辑
摘要: Sort a linked list using insertion sort. Example Given 1->3->2->0->null, return 0->1->2->3->null. 思路也比较直接,insertion sort,要注意的就是操作linkedlist的一些问题 /** * 阅读全文
posted @ 2016-02-25 15:38 哥布林工程师 阅读(165) 评论(0) 推荐(0) 编辑
摘要: Given a binary search tree and a new tree node, insert the node into the tree. You should keep the tree still be a valid binary search tree. Example G 阅读全文
posted @ 2016-02-25 14:35 哥布林工程师 阅读(171) 评论(0) 推荐(0) 编辑
摘要: Given a non-overlapping interval list which is sorted by start point. Insert a new interval into it, make sure the list is still in order and non-over 阅读全文
posted @ 2016-02-25 13:50 哥布林工程师 阅读(313) 评论(0) 推荐(0) 编辑
摘要: Check if two binary trees are identical. Identical means the two binary trees have the same structure and every identical position has the same value. 阅读全文
posted @ 2016-02-25 08:22 哥布林工程师 阅读(196) 评论(0) 推荐(0) 编辑
摘要: In data structure Hash, hash function is used to convert a string(or any other type) into an integer smaller than hash size and bigger or equal to zer 阅读全文
posted @ 2016-02-25 08:11 哥布林工程师 阅读(286) 评论(0) 推荐(0) 编辑
摘要: Write an algorithm to determine if a number is happy. A happy number is a number defined by the following process: Starting with any positive integer, 阅读全文
posted @ 2016-02-25 07:35 哥布林工程师 阅读(306) 评论(0) 推荐(0) 编辑
摘要: Determine the number of bits required to flip if you want to convert integer n to integer m. Example Given n = 31 (11111), m = 14 (01110), return 2. N 阅读全文
posted @ 2016-02-24 18:28 哥布林工程师 阅读(109) 评论(0) 推荐(0) 编辑
摘要: Flatten a binary tree to a fake "linked list" in pre-order traversal. Here we use the right pointer in TreeNode as the nextpointer in ListNode. Exampl 阅读全文
posted @ 2016-02-24 18:24 哥布林工程师 阅读(198) 评论(0) 推荐(0) 编辑
摘要: For a given sorted array (ascending order) and atarget number, find the first index of this number inO(log n) time complexity. If the target number do 阅读全文
posted @ 2016-02-24 17:53 哥布林工程师 阅读(217) 评论(0) 推荐(0) 编辑