10 2016 档案
摘要:Design and implement a data structure for Least Recently Used (LRU) cache. It should support the following operations: get and set. get(key) - Get the
阅读全文
摘要:public class Heap where T : IComparable { private List elements = new List(); public int GetSize() { return elements.Count; } public ...
阅读全文
摘要:sum无非两种情况,用hashtable 或者用 2 pointer。 Hashtable的时候多不需要考虑重复问题,但是2 pointer往往要考虑重复问题。解决重复问题的方法为初始时判断,如果不是i=0或者nums[i] != nums[i-1],那就跳过。这样保证第一个值不可能是一样的。同理,
阅读全文
摘要:Step 1: Who is going to use it. How they are going to use it. Or: Who, What, Where, When, how, Why Step 2: Define Core Objects. Example: Resaturant: T
阅读全文
摘要:作为log(n) search 方法的典型, Binary Search基本可以分为以下几类 下面逐个解说: 1. 准确number, 这个比较简单,就是可以分为3中情况,mid等于,mid小于,mid大于。不赘述,具体code如下 几个典型的题为 2. 3. First Bad Version.
阅读全文
摘要:Given n non-negative integers representing an elevation map where the width of each bar is 1, compute how much water it is able to trap after raining.
阅读全文
摘要:Given an integer array of size n, find all elements that appear more than ⌊ n/3 ⌋ times. The algorithm should run in linear time and in O(1) space. Hi
阅读全文
摘要:The thief has found himself a new place for his thievery again. There is only one entrance to this area, called the "root." Besides the root, each hou
阅读全文
摘要:Given a complete binary tree, count the number of nodes. http://www.programcreek.com/2014/06/leetcode-count-complete-tree-nodes-java/
阅读全文
摘要:Given n, how many structurally unique BST's (binary search trees) that store values 1...n? For example,Given n = 3, there are a total of 5 unique BST'
阅读全文