Sharing some common interview preparation materials through this reporsity.
- Data Structure and Algorithm
- System Design && Object-Oriented Design
- Computer Science and programming language knowledge, APIs, best practice, JVM mechanism & turning
- Behavior Question & Project/Technical Knowledge Dive Deep
Strategies:
- Easy + Medium first, then Hard. Focus on Medium level.
- In preparation stage, categories based; in final stage (one or two weeks before interviewing), company tag based.
- Think 10 - 20 minutes, if no clues, read the discussions. Do not spend more than 30 minutes on each problem.
- Write all solutions.
- Summarize similar problems.
Categories (Data Structure & Algorithms):
- Sort
- Quick Sort, Merge Sort
- Quick Select
- LinkedList
- Heap (or Priority Queue), Stack, Queue, Hash (HashMap, HashSet)
- Binary Search
- 2 Pointers
- 2 Pointers
- Sliding Window
- BFS
- DFS
- DP
Others (Data Structure & Algorithms & Design):
- Union Find
- Trie
- Monotone Stack / Queue
- Sweep Line
- TreeMap
- Bit Manipulation
- Math
- Randomized
- Design
- Prefix Sum
- Segment Tree, Binary Index Tree, Minimum Spanning Tree
Array includes N-Sum series, operation to array(rotate or pivot). DFS or BFS search a subset of array, e.g combination.
Binary Search is also a hot topic for sorted array. When see the coding problem requires O(logN) time complexity to search something in a sorted array, then it's probably using Binary Search.
Give an array, always ask interview: if the array is sorted? Could we sort the array if necessary? If the array is empty or null? If that could be huge array that will be out of memory?
Note:
- If a topic is about DP or Greedy, it's put to DP section, e.g. 45. Jump Game II.
|★78.Subsets|LeetCode-78-Subsets.java|DFS| |90.Subsets II|LeetCode-90-Subsets-II.java|DFS|
String includes Parentheness series, Palindrome series, Anagram series, some statistic problems.
回文串问题总结
LeetCode总结 —— Palindrome 回文总结
最长回文字符串、二重循环
「LeetCode」试题总结 - 回文数汇总
|242.Valid Anagram|LeetCode-242-Valid-Anagram.java|Sort, Array Map| |32.Longest Valid Parentheses|LeetCode-32-Longest-Valid-Parentheses.java|Not Yet| |241.Different Ways to Add Parentheses|LeetCode-241.Different Ways to Add Parentheses.java|Not Yet| |9 Palindrome Number|LeetCode-9-Palindrome-Number.java|Math| |234.Palindrome Linked List|LeetCode-234-Palindrome-Linked-List.java|LinkedList| |131.Palindrome Partitioning|LeetCode-131-Palindrome-Partitioning.java|DFS| |★132.Palindrome Partitioning II|LeetCode-132-Palindrome-Partitioning-II.java|DP| |214.Shortest Palindrome|LeetCode-214-Shortest-Palindrome.java|Not Yet, Hard| |266.Palindrome Permutation|LeetCode-266-Palindrome-Permutation.java|HashMap| |267.Palindrome Permutation II|LeetCode-267-Palindrome-Permutation-II.java|Not Yet| |288.Unique Word Abbreviation|LeetCode-288-Unique-Word-Abbreviation.java|String|
|680. Valid Palindrome II|LeetCode-680-Valid-Palindrome-II.java|Not Yet|
Search in Tree, in Binary Tree, Binary Search Tree, in String, in Array
Search a required set, search Maximum/Minimu result
- 求二叉树中的节点个数: getNodeNumRec(递归),getNodeNum(迭代)
- 求二叉树的深度: getDepthRec(递归),getDepth
- ★★★前序遍历,中序遍历,后序遍历: preorderTraversalRec, preorderTraversal, inorderTraversalRec, postorderTraversalRec
- ★★★分层遍历二叉树(按层次从上往下,从左往右):levelTraversal, levelTraversalRec(递归解法)
- 将二叉查找树变为有序的双向链表: convertBST2DLLRec, convertBST2DLL
- 求二叉树第K层的节点个数:getNodeNumKthLevelRec, getNodeNumKthLevel
- 求二叉树中叶子节点的个数:getNodeNumLeafRec, getNodeNumLeaf
- 判断两棵二叉树是否相同的树:isSameRec, isSame
- 判断二叉树是不是平衡二叉树:isAVLRec
- 求二叉树的镜像(破坏和不破坏原来的树两种情况):
mirrorRec, mirrorCopyRec
mirror, mirrorCopy
10.1 判断两个树是否互相镜像:isMirrorRec isMirror - 求二叉树中两个节点的最低公共祖先节点:
LAC 求解最小公共祖先, 使用list来存储path
LCABstRec 递归求解BST树
LCARec 递归算法 - 求二叉树中节点的最大距离:getMaxDistanceRec
- 由前序遍历序列和中序遍历序列重建二叉树:rebuildBinaryTreeRec
- 判断二叉树是不是完全二叉树:isCompleteBinaryTree, isCompleteBinaryTreeRec
- 找出二叉树中最长连续子串(即全部往左的连续节点,或是全部往右的连续节点): findLongest
面试大总结之二:Java搞定面试中的二叉树题目
轻松搞定面试中的二叉树题目
算法大全(3)二叉树
Question | Solution | Tags |
---|---|---|
301.Remove Invalid Parentheses | LeetCode-301-Remove-Invalid-Parentheses.java | DFS, BFS, String |
314.Binary Tree Vertical Order Traversal | LeetCode-314-Binary-Tree-Vertical-Order-Traversal.java | DFS, BFS, Traversal |
987. Vertical Order Traversal of a Binary Tree | LeetCode-987-Vertical-Order-Traversal-of-a-Binary-Tree.java | DFS, BFS, Traversal |
Question | Solution | Tags |
---|---|---|
317. Shortest Distance from All Buildings | LeetCode-317-Shortest-Distance-from-All-Buildings.java | BFS, Matrix |
1091. Shortest Path in Binary Matrix | LeetCode-1091-Shortest-Path-in-Binary-Matrix.java | BFS, Matrix |
Change Order(Reverse, Swap) & Remove
The use of dummy node, use pointer Next to store next node(Merge Two Sort Lists, Merge K Sorted Lists, Reverse List, Reverse Nodes in K-groups)
Find/Remove Kth biggest node from end: use two pointers, one run k step, and then two pointers run parallelly until one reach null.
Find the middle of a list: fast-slow pointers, one run one step, another run two steps. Be carefully of initialization, slow = header, fast = header.next.(Find intersection point, Detect circle)
面试大总结之链表
轻松搞定面试中的链表题目
算法大全(1)单链表
PriorityQueue.
Question | Solution | Tags |
---|---|---|
133.Clone Graph | LeetCode-133-Clone-Graph.java | Graph, BFS, DFS |
207. Course Schedule | LeetCode-207-Course-Schedule.java | Graph, Topological Sort |
210. Course Schedule II | LeetCode-210-Course-Schedule-II.java | Graph, Topological Sort |
269. Alien Dictionary | LeetCode-269-Alien-Dictionary.java | Graph, Topological Sort |
785. Is Graph Bipartite? | LeetCode-785-Is-Graph-Bipartite.java | Graph, Topological Sort |
Question | Solution | Tags |
---|---|---|
523. Continuous Subarray Sum | LeetCode-523-Continuous-Subarray-Sum.java | Prefix Sum, Array |
Prime
Operations between strings, between big numbers(larger than RAM: First external sorting (split into several parts), then K-way merge.)
|60.Permutation Sequence|LeetCode-60-Permutation-Sequence.java|Math| |168.Excel Sheet Column Title|LeetCode-168-Excel-Sheet-Column-Title.java|Math| |171.Excel Sheet Column Number|LeetCode-171-Excel-Sheet-Column-Number.java|Math|
Question | Solution | Tags |
---|---|---|
187. Repeated DNA Sequences | LeetCode-187-Repeated-DNA-Sequences.java | Bit Manipulation |
190. Reverse Bits | LeetCode-190-Reverse-Bits.java | Bit Manipulation |
191. Number of 1 Bits | LeetCode-191-Number-of-1-Bits.java | Bit Manipulation |
201. Bitwise AND of Numbers Range | LeetCode-201-Bitwise-AND-of-Numbers-Range.java | Bit Manipulation |
260.Single Number III | LeetCode-260-Single-Number-III.java | Bit Manipulation |
318. Maximum Product of Word Lengths | LeetCode-318-Maximum-Product-of-Word-Lengths.java | Math |
393. UTF-8 Validation | LeetCode-393-UTF-8-Validation.java | Math |
https://leetcode.com/tag/stack/
https://leetcode.com/tag/monotonic-stack/
Question | Solution | Tags |
---|---|---|
85. Maximal Rectangle | LeetCode-85-Maximal-Rectangle.java | Stack |
1762. Buildings With an Ocean View | LeetCode-1762-Buildings-With-an-Ocean-View.java | Stack |
https://leetcode.com/tag/queue/
Question | Solution | Tags |
---|---|---|
379. Design Phone Directory | LeetCode-379-Design-Phone-Directory.java | Queue |
Question | Solution | Tags |
---|---|---|
128. Longest Consecutive Sequence | LeetCode-128-Longest-Consecutive-Sequence.java | Array, Union-Find |
261. Graph Valid Tree | LeetCode-261-Graph-Valid-Tree.java | Graph, Union-Find, DFS, BFS |
323. Number of Connected Components in an Undirected Graph | LeetCode-323-Number-of-Connected-Components-in-an-Undirected-Graph.java | Graph, Union-Find, DFS, BFS |
547. Friend Circles | LeetCode-547-Friend-Circles.java | Union-Find, DFS |
Question | Solution | Tags |
---|---|---|
382. Linked List Random Node | LeetCode-382-Linked-List-Random-Node.java | Reservoir Sampling |
Question | Solution | Tags |
---|---|---|
715. Range Module | LeetCode-715-Range-Module.java | Segment Tree, TreeMap |
173.Binary Search Tree Iterator
136.Single Number
137.Single Number II
30.Substring with Concatenation of All Words
/* LeetCode: LintCode: JiuZhang: ProgramCreek:
Analysis:
*/
Category
经典面试题总结 —— Binary Search 及其变种
BFS/DFS总结
转一些我blog上一些常见的二叉树面试问题和总结 (更新)
Here is a 10-line template that can solve most 'substring' problems
Backtracking Porblems总结(Subsets-Permutations-Combination-Sum-Palindrome-Partitioning)
刷题总结: http://joshuablog.herokuapp.com/Leetcode-%E6%80%BB%E7%BB%93.html
LeetCode | LintCode | JiuZhang
Top 10 Algorithms for Coding Interview
Top 10 algorithms in Interview Questions(G4G)
Simple Java
Data Structure Summary