0. 零基礎入門
Coding interview exposed (3ed) 這個最簡單了,基礎比較挫的可以從這里開始
“這本書籍不是“課本”,不是“課程”,而是教你做各種常見面試題目的。熟練掌握這本書籍的內容,是你找到工作的基礎。”
Programming Interviews Exposed 8.0/60 | 程序員面試攻略 7.7/86
MIT的Hacking a google interview(也非常簡單)
1. 系統學習 - 不能滿足於給出解法,復雜度分析一樣重要
careercup不難,參考二爺划的重點,早早開始做,即使先開始做前幾章簡單的。
Cracking the Coding Interview v5 8.9/88
挑戰程序設計競賽 9.0/72
編程之美 8.3/2289
劍指offer 8.3/159
編程珠璣 9.2/1215
復雜度分析要善於總結歸納,不妨看看算法之排序算法,一圖勝千言
2. 真題 - 時間有限,編碼真題練手是最直接的。
最好的教材自然就是careercup (類似的網站還有glassdoor)
3. OJ - Bug Free&Code Style比攻克難題更重要
OJ有反饋保持手感,對非ACM選手,即使是google的面試也不會太難
leetcode的題稍難一些,不過很有趣,可以參考這份難度系數表刷題(文末有附),還有一個tips(北美求職群主分類題解/九章的答案/maskray答案)
codility 有分類,可以鍛煉舉一反三能力,比Leetcode更適合入門
九度Online Judge (基於《劍指Offer》)
如果有余力,還有很多OJ網站:
interviewstreet (一些海外公司的筆試平台)
google code jam google面可以做做
4 簡歷和behavior question
What A GOOD Resume Should Look Like
The Google Resume 8.2/38 | 金領簡歷 8.2/20
behavior question,准備一些類似於自我介紹、為什么xx公司一類的就行,其它的知道怎么回答就行。http://hrinterviews.blogspot.com/ (64道behavior questions)。
5.系統設計
6.資訊
7. 網絡資源
結構之法 算法之道 July的博客
程序員編程藝術 July的新書
劍指Offer:名企面試官精講典型編程題 何海濤的博客
mitbbs的JobHunting版(需翻牆)
大牛制定的MIT算法導論公開課學習計划,配套精選的ACM題
8.其他可供消(shao)遣(qian)的書籍
大話數據結構 8.1/336
大話設計模式 8.3/1139
鳥哥的Linux私房菜.基礎學習篇 9.1/1097
UNIX環境高級編程 9.4/1531
UNIX編程藝術 9.1/1651
人人都有好工作 7.9/45
誰是谷歌想要的人才 7.4/195
浪潮之巔 9.1/10221
黑客與畫家 8.8/7032
暗時間 8.5/4871
程序員面試寶典 6.1/118(強烈土豪購買這本用來燒錢...里面很多錯誤,找到就是賺到)
參考:
http://www.1point3acres.com/bbs/thread-50411-1-1.html
http://www.zzsec.org/tags.html#leetcode-ref
附:
leetcode Questions
Id | Question | Difficulty | Freqency | Data Structures | Algorithms |
1 | Two Sum | 2 | 5 | array, set | sort, two pointers |
8 | String to Integer (atoi) | 2 | 5 | string | math |
20 | Valid Parentheses | 2 | 5 | string | stack |
21 | Merge Two Sorted Lists | 2 | 5 | linked list | sort, two pointers, merge |
65 | Valid Number | 2 | 5 | string | math |
70 | Climbing Stairs | 2 | 5 | dp | |
88 | Merge Sorted Array | 2 | 5 | array | two pointers, merge |
125 | Valid Palindrome | 2 | 5 | string | two pointers |
15 | 3Sum | 3 | 5 | array | two pointers |
50 | Pow(x, n) | 3 | 5 | binary search, math | |
73 | Set Matrix Zeroes | 3 | 5 | array | |
98 | Validate Binary Search Tree | 3 | 5 | tree | dfs |
127 | Word Ladder | 3 | 5 | graph | bfs, shortest path |
28 | Implement strStr() | 4 | 5 | string | two pointers, KMP, rolling hash |
56 | Merge Intervals | 4 | 5 | array, linked list, red-black tree | sort, merge |
57 | Insert Interval | 4 | 5 | array, linked list, red-black tree | sort, merge |
27 | Remove Element | 1 | 4 | array | two pointers |
13 | Roman to Integer | 2 | 4 | math | |
24 | Swap Nodes in Pairs | 2 | 4 | linked list | |
67 | Add Binary | 2 | 4 | string | two pointers, math |
129 | Sum Root to Leaf Numbers | 2 | 4 | tree | dfs |
2 | Add Two Numbers | 3 | 4 | linked list | two pointers, math |
12 | Integer to Roman | 3 | 4 | math | |
22 | Generate Parentheses | 3 | 4 | string | dfs |
23 | Merge k Sorted Lists | 3 | 4 | linked list, heap | sort, two pointers, merge |
46 | Permutations | 3 | 4 | array | permutation |
49 | Anagrams | 3 | 4 | string, hashtable | |
77 | Combinations | 3 | 4 | combination | |
78 | Subsets | 3 | 4 | array | recursion, combination |
79 | Word Search | 3 | 4 | array | dfs |
91 | Decode Ways | 3 | 4 | string | recursion, dp |
102 | Binary Tree Level Order Traversal | 3 | 4 | tree | bfs |
131 | Palindrome Partitioning | 3 | 4 | string | dfs |
69 | Sqrt(x) | 4 | 4 | binary search | |
26 | Remove Duplicates from Sorted Array | 1 | 3 | array | two pointers |
83 | Remove Duplicates from Sorted List | 1 | 3 | linked list | |
112 | Path Sum | 1 | 3 | tree | dfs |
7 | Reverse Integer | 2 | 3 | math | |
19 | Remove Nth Node From End of List | 2 | 3 | linked list | two pointers |
62 | Unique Paths | 2 | 3 | array | dp |
108 | Convert Sorted Array to Binary Search Tree | 2 | 3 | tree | dfs |
17 | Letter Combinations of a Phone Number | 3 | 3 | string | dfs |
39 | Combination Sum | 3 | 3 | array | combination |
53 | Maximum Subarray | 3 | 3 | array | dp |
63 | Unique Paths II | 3 | 3 | array | dp |
64 | Minimum Path Sum | 3 | 3 | array | dp |
74 | Search a 2D Matrix | 3 | 3 | array | binary search |
82 | Remove Duplicates from Sorted List II | 3 | 3 | linked list | recursion, two pointers |
86 | Partition List | 3 | 3 | linked list | two pointers |
93 | Restore IP Addresses | 3 | 3 | string | dfs |
105 | Construct Binary Tree from Preorder and Inorder Tr | 3 | 3 | array, tree | dfs |
106 | Construct Binary Tree from Inorder and Postorder T | 3 | 3 | array, tree | dfs |
114 | Flatten Binary Tree to Linked List | 3 | 3 | tree | recursion, stack |
116 | Populating Next Right Pointers in Each Node | 3 | 3 | tree | dfs |
29 | Divide Two Integers | 4 | 3 | binary search, math | |
33 | Search in Rotated Sorted Array | 4 | 3 | array | binary search |
34 | Search for a Range | 4 | 3 | array | binary search |
43 | Multiply Strings | 4 | 3 | string | two pointers |
51 | N-Queens | 4 | 3 | array | dfs |
52 | N-Queens II | 4 | 3 | array | dfs |
72 | Edit Distance | 4 | 3 | string | dp |
94 | Binary Tree Inorder Traversal | 4 | 3 | tree, hashtable | recursion, morris, stack |
103 | Binary Tree Zigzag Level Order Traversal | 4 | 3 | queue, tree | bfs, stack |
109 | Convert Sorted List to Binary Search Tree | 4 | 3 | linked list | recursion, two pointers |
128 | Longest Consecutive Sequence | 4 | 3 | array | |
130 | Surrounded Regions | 4 | 3 | array | bfs, dfs |
132 | Palindrome Partitioning II | 4 | 3 | string | dp |
4 | Median of Two Sorted Arrays | 5 | 3 | array | binary search |
10 | Regular Expression Matching | 5 | 3 | string | recursion, dp |
44 | Wildcard Matching | 5 | 3 | string | recursion, dp, greedy |
81 | Search in Rotated Sorted Array II | 5 | 3 | array | binary search |
66 | Plus One | 1 | 2 | array | math |
101 | Symmetric Tree | 1 | 2 | tree | dfs |
110 | Balanced Binary Tree | 1 | 2 | tree | dfs |
9 | Palindrome Number | 2 | 2 | math | |
35 | Search Insert Position | 2 | 2 | array | |
36 | Valid Sudoku | 2 | 2 | array | |
38 | Count and Say | 2 | 2 | string | two pointers |
80 | Remove Duplicates from Sorted Array II | 2 | 2 | array | two pointers |
113 | Path Sum II | 2 | 2 | tree | dfs |
3 | Longest Substring Without Repeating Characters | 3 | 2 | string, hashtable | two pointers |
11 | Container With Most Water | 3 | 2 | array | two pointers |
18 | 4Sum | 3 | 2 | array | |
55 | Jump Game | 3 | 2 | array | |
59 | Spiral Matrix II | 3 | 2 | array | |
61 | Rotate List | 3 | 2 | linked list | two pointers |
92 | Reverse Linked List II | 3 | 2 | linked list | two pointers |
5 | Longest Palindromic Substring | 4 | 2 | string | |
25 | Reverse Nodes in k-Group | 4 | 2 | linked list | recursion, two pointers |
37 | Sudoku Solver | 4 | 2 | array | dfs |
40 | Combination Sum II | 4 | 2 | array | combination |
42 | Trapping Rain Water | 4 | 2 | array | two pointers, stack |
45 | Jump Game II | 4 | 2 | array | |
47 | Permutations II | 4 | 2 | array | permutation |
48 | Rotate Image | 4 | 2 | array | |
54 | Spiral Matrix | 4 | 2 | array | |
68 | Text Justification | 4 | 2 | string | |
75 | Sort Colors | 4 | 2 | array | sort, two pointers |
76 | Minimum Window Substring | 4 | 2 | string | two pointers |
89 | Gray Code | 4 | 2 | combination | |
90 | Subsets II | 4 | 2 | array | recursion, combination |
99 | Recover Binary Search Tree | 4 | 2 | tree | dfs |
115 | Distinct Subsequences | 4 | 2 | string | dp |
117 | Populating Next Right Pointers in Each Node II | 4 | 2 | tree | dfs |
124 | Binary Tree Maximum Path Sum | 4 | 2 | tree | dfs |
31 | Next Permutation | 5 | 2 | array | permutation |
41 | First Missing Positive | 5 | 2 | array | sort |
84 | Largest Rectangle in Histogram | 5 | 2 | array | stack |
87 | Scramble String | 5 | 2 | string | recursion, dp |
97 | Interleaving String | 5 | 2 | string | recursion, dp |
58 | Length of Last Word | 1 | 1 | string | |
100 | Same Tree | 1 | 1 | tree | dfs |
104 | Maximum Depth of Binary Tree | 1 | 1 | tree | dfs |
111 | Minimum Depth of Binary Tree | 1 | 1 | tree | dfs |
126 | Word Ladder II | 1 | 1 | ||
14 | Longest Common Prefix | 2 | 1 | string | |
118 | Pascal's Triangle | 2 | 1 | array | |
119 | Pascal's Triangle II | 2 | 1 | array | |
121 | Best Time to Buy and Sell Stock | 2 | 1 | array | dp |
6 | ZigZag Conversion | 3 | 1 | string | |
16 | 3Sum Closest | 3 | 1 | array | two pointers |
30 | Substring with Concatenation of All Words | 3 | 1 | string | two pointers |
71 | Simplify Path | 3 | 1 | string | stack |
96 | Unique Binary Search Trees | 3 | 1 | tree | dp |
107 | Binary Tree Level Order Traversal II | 3 | 1 | tree | bfs |
120 | Triangle | 3 | 1 | array | dp |
122 | Best Time to Buy and Sell Stock II | 3 | 1 | array | greedy |
32 | Longest Valid Parentheses | 4 | 1 | string | dp |
95 | Unique Binary Search Trees II | 4 | 1 | tree | dp, dfs |
123 | Best Time to Buy and Sell Stock III | 4 | 1 | array | dp |
60 | Permutation Sequence | 5 | 1 | permutation, math | |
85 | Maximal Rectangle | 5 | 1 | array | dp, stack |
很可惜二爺不再更新了,未名上Jc2013補充了一點新題
1. Clone Graph-> BFS+HashMap
2. Gas Station->DP
3. Candy->Two Pointers
4. Single Number-> Xor, HashMap, or Sum or Product way to find
5. Single Number II -> Xor, HashMap
6. Copy List with Random Pointers -> Two Pointers, HashMap with two times
traverse(like clone graph)
7. List Cycle, List Cycle II, Reorder List-> Two Pointers
8. Binary Tree Preorder, Postorder recursive -> Using stack to mock
recursive way, or implement like morris way.
9. LRU Cache-> HashMap + list
10. Insertion sort list -> Two Pointers
11. Sort List-> I implement merge sort, still, two pointers method,
combination of merge sort list and split
list
12. Word Break -> DFS DP
13. Word Break II -> DP + Backtracking
很多人都說把這150題做了一遍或幾遍,但是我感覺算法題才是重點,其他的很多題面
試基本碰不上,沒看出來有必要全做。這里總結一下自己認為重要的題。
第一章 :
全部重要 (1.6, 1.7 Leetcode上有)。
1.5 面A碰到 (string compression)
1.7面Z碰到 (set 0)
1.8面Bigfish碰到 (string rotation)
第二章 (2.4, 2.5 Leetcode上有):
全部重要。
2.2面Bigfish碰到 (find kth)
第三章 :
感覺就是3.2 (min stack), 3.5 (two stack queue) 重要。兩道題面M被問到過。3.6
(sort stack)感覺也有可能被考到。
第四章 (4.1, 4.3, 4.5 Leetcode上有):
感覺4.2, 4.3, 4.5,4.6, 4.7 重要。4.5 (valid BST)面E,Q碰到過
第五章:5.4 (n & (n-1))
第六章:6.5 (drop egg)
第七章:7.3 (line intersection),7.6 (line passes most points)
第八章:8.4 (parking lot), 8.10 (hashtable)
第九章 (9.1, 9.2, 9.5, 9.6,9.8,9.9 Leetcode上有):
感覺都重要 (9.10 (stack of boxes), 9.11 (boolean expression) 貌似可以忽略
)。
第十章(10.1, 10.2, 10.3 Leetcode上有):
10.1 (merge) M碰到過兩次
10.3
10.4 (external sort) E碰到
10.6
第十七章(17.8, 17.12, 17.13 Leetcode上有):
17.1 (swap number)
17.2 (tic-tac-toe) 面I遇到過
17.7 (integer->english)
17.8 (largest sum) 經典, 注意變形題 (largest product), 面RF碰到過
17.9 (frequency of occurrences) S碰到
17.11 (rand7)
17.12 (2 sum) G碰到
17.13 (BT -> Linkedlist)
第十八章(9):
18.2 (shuffle deck) 貌似經典
18.3 (random)
18.4 (count 2s) 注意思路,可能會出現類似題
18.5 (shortest distance)
18.6 (quick select) 面Z, G碰到類似題
18.9-18.12
一共50道題。其他很多題可以做練習,但是面試碰到的概率不大。上邊一些題面試也很
難碰到但是是不可不練的題,比如八皇后。另外就是別完全follow書上的答案,注意看
有沒有bug。希望大家能補充一下自己認為重要的。
二爺的DP總結
“不斷看到有新人學習DP,想談談我的感受。
我大概是去年底,今年初開始學習DP的。以前沒有一點概念。去年G電面我的時候就出
了一道最簡單的DP題,那時我根本不知道什么是DP,在提示下用recursion做出來的,
沒有用cache。
開始學習DP是在careercup 150那本書上。下面是一些感受。
1. careercup定義的DP就是recursion+cache。這個定義指導了我很長時間。我認為這
個定義是DP的初級階段,有誤導性,使得我在練習的時候發現很多題型用這個定義套不
上。誤導性在於: 1, recursion+cache是DP不錯,但是DP並不等於recursion+cache。
2, recursion的DP並不優化,因此從recursion出發做DP不是個好思路。
2. 我后來理解的DP是這樣子的。很簡單就是推DP公式。也就是說怎么用F(n-i) 推導出
F(n)來。當然這也是最難的。發現很多難題還是很難想到這個公式的,可能就得多練習
了,培養思路。這個定義跟careercup上的不一樣的地方主要是思考的方式不同,一個
是推公式,一個是找recursion的辦法。而DP的關鍵是推公式,如果從recursion出發的
話,很多題可能做不出來。
做DP題需要注意兩點:
1. 能用iteration就不要用recursion。這也證明了careercup上的定義有局限性了。
2. DP是用空間換時間。所以DP題做熟了,應該考慮怎樣優化空間了。能用常數空間就
不要用O(n), 能用O(n)就不要用O(n^2). (我覺得這也是Vissa的霸氣所在。Vissa面F
的時候說過“這么簡單的DP題,我從來都是用常數空間”)。
最后就是多做題才能培養思路。一般面試應該不會有很難的DP題,多練習一下有了思路
,再能寫出iteration和空間優化的解法,並且能保證少bug的話,應該面試就差不多了。”