遍历,一共有三种情况, 1. pre <= x <= current 2. 遍历到了head时,x>tail 或者 x<=head (不会等于tail) 3. 遍历回aNode或同值的Node,此时直接插到此Node的前面 public void insert(Node aNode, int x) { ListNode last = aNode; ListNode current = aNode.next; while (current.val != aNode.val) { if…
Description   Insert a node in a sorted linked list.   Example Example 1: Input: head = 1->4->6->8->null, val = 5 Output: 1->4->5->6->8->null Example 2: Input: head = 1->null, val = 2 Output: 1->2->null-----------------…
Insert a node in a sorted linked list. Have you met this question in a real interview?  Yes Example Given list = 1->4->6->8 and val = 5. Return 1->4->5->6->8. 分析 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27…
Insert a node in a sorted linked list. Example Given list = 1->4->6->8 and val = 5. Return 1->4->5->6->8. 解法一: /** * Definition of ListNode * class ListNode { * public: * int val; * ListNode *next; * ListNode(int val) { * this->val…
Trie 树, 又称字典树,单词查找树.它来源于retrieval(检索)中取中间四个字符构成(读音同try).用于存储大量的字符串以便支持快速模式匹配.主要应用在信息检索领域. Trie 有三种结构: 标准trie (standard trie).压缩trie.后缀trie(suffix trie) . 最后一种将在<字符串处理4:后缀树>中详细讲,这里只将前两种. 1. 标准Trie (standard trie) 标准 Trie树的结构 : 所有含有公共前缀的字符串将挂在树中同一个结点下…
/////转自http://blog.csdn.net/suxinpingtao51/article/details/8015147#userconsent# 微软亚洲技术中心的面试题!!! 1.进程和线程的差别. 线程是指进程内的一个执行单元,也是进程内的可调度实体.与进程的区别:(1)调度:线程作为调度和分配的基本单位,进程作为拥有资源的基本单位(2)并发性:不仅进程之间可以并发执行,同一个进程的多个线程之间也可并发执行(3)拥有资源:进程是拥有资源的独立单位,线程不拥有系统资源,但可以访问…
Time complexity: Binary search O(log2 n): i=0.   n elements:         ------------------- i=1.   n/2 elements:                   ---------- i=2.   n/4 elements:                          ----- ... i=i.    n/2^i elements:                        - 进行n/2^…
参考链接:https://docs.google.com/spreadsheet/pub?key=0Aqt--%20wSNYfuxdGxQWVFsOGdVVWxQRlNUVXZTdEpOeEE&output=html ID Question Diff Freq Data Structure Algorithms                                   1 Two Sum 2 5 array sort           set Two Pointers   2 Add…
微软亚洲技术中心的面试题!!! .进程和线程的差别. 线程是指进程内的一个执行单元,也是进程内的可调度实体. 与进程的区别: (1)调度:线程作为调度和分配的基本单位,进程作为拥有资源的基本单位 (2)并发性:不仅进程之间可以并发执行,同一个进程的多个线程之间也可并发执行 (3)拥有资源:进程是拥有资源的独立单位,线程不拥有系统资源,但可以访问隶属于进程的资源.  (4)系统开销:在创建或撤消进程时,由于系统都要为之分配和回收资源,导致系统的开销明显大于创建或撤消线程时的开销. 2.测试方法 人…
转载自:LeetCode Question Difficulty Distribution                 1 Two Sum 2 5 array sort           set Two Pointers   2 Add Two Numbers 3 4 linked list Two Pointers             Math   3 Longest Substring Without Repeating Characters 3 2 string Two Poin…