摘要: Design an algorithm and write code to serialize and deserialize a binary tree. Writing the tree to a file is called 'serialization' and reading back f... 阅读全文
posted @ 2015-05-20 15:03 Joyce-Lee 阅读(181) 评论(0) 推荐(0) 编辑
摘要: Given a BST, find 2 nodes in it which sum to a given targethint:Inorder traversal + BST + 2 SUM* Time : O(N)* Space: O(lgN) 1 class TreeNode0 { 2 ... 阅读全文
posted @ 2015-05-20 12:01 Joyce-Lee 阅读(327) 评论(0) 推荐(0) 编辑
摘要: Given an unsorted array, find the maximum difference between the successive elements in its sorted form.Try to solve it in linear time/space.Return 0 ... 阅读全文
posted @ 2015-05-20 07:08 Joyce-Lee 阅读(256) 评论(0) 推荐(0) 编辑
摘要: Given one point P0 on a 2-dimension space.There are n other points on the same space.Try to find K points which are most closed to P0.hint: Part ofQu... 阅读全文
posted @ 2015-05-20 07:01 Joyce-Lee 阅读(247) 评论(0) 推荐(0) 编辑
摘要: Give you an integer array (index from 0 to n-1, where n is the size of this array, value from 0 to 10000) and an query list. For each query, give you ... 阅读全文
posted @ 2015-05-20 06:51 Joyce-Lee 阅读(319) 评论(0) 推荐(0) 编辑
摘要: Given an Array, find the number of inversion couples in the Arraye.g. 2, 4, 3, 1 4 -> (2,1), (3,1), (4,1), (4,3)hint:Solution 1* Iterate the whole a... 阅读全文
posted @ 2015-05-20 06:25 Joyce-Lee 阅读(202) 评论(0) 推荐(0) 编辑
摘要: Given an ArrayList and a function " boolean test(someObject obj) "Test every element in the array list, delete all element that returns Fwith minimum ... 阅读全文
posted @ 2015-05-20 06:20 Joyce-Lee 阅读(213) 评论(0) 推荐(0) 编辑
摘要: 各种 Sort 算法,包括 Quick Sort, Merge Sort, Heap Sort, Count Sort 1 package Sort; 2 3 public class Sort { 4 /* 5 * Quick Sort 6 * Tim... 阅读全文
posted @ 2015-05-20 06:09 Joyce-Lee 阅读(266) 评论(0) 推荐(0) 编辑
摘要: The diameter of a tree (sometimes called the width) is the number of nodes on the longest path between two leaves in the tree.The diameter of a tree T... 阅读全文
posted @ 2015-05-20 05:41 Joyce-Lee 阅读(336) 评论(0) 推荐(0) 编辑