leetcode
Preface
1.
Part I - Basics
2.
Basics Data Structure
2.1.
String
2.2.
Linked List
2.3.
Binary Tree
2.4.
Huffman Compression
2.5.
Queue
2.6.
Heap
2.7.
Stack
2.8.
Set
2.9.
Map
2.10.
Graph
3.
Basics Sorting
3.1.
Bubble Sort
3.2.
Selection Sort
3.3.
Insertion Sort
3.4.
Merge Sort
3.5.
Quick Sort
3.6.
Heap Sort
3.7.
Bucket Sort
3.8.
Counting Sort
3.9.
Radix Sort
4.
Basics Algorithm
4.1.
Divide and Conquer
4.2.
Binary Search
4.3.
Math
4.3.1.
Greatest Common Divisor
4.3.2.
Prime
4.4.
Knapsack
4.5.
Counting Problem
4.6.
Probability
4.6.1.
Shuffle
4.7.
Bitmap
5.
Basics Misc
5.1.
Bit Manipulation
6.
Part II - Coding
7.
String
7.1.
strStr
7.2.
Two Strings Are Anagrams
7.3.
Compare Strings
7.4.
Anagrams
7.5.
Longest Common Substring
7.6.
Rotate String
7.7.
Reverse Words in a String
7.8.
Valid Palindrome
7.9.
Longest Palindromic Substring
7.10.
Space Replacement
7.11.
Wildcard Matching
7.12.
Length of Last Word
7.13.
Count and Say
8.
Integer Array
8.1.
Remove Element
8.2.
Zero Sum Subarray
8.3.
Subarray Sum K
8.4.
Subarray Sum Closest
8.5.
Recover Rotated Sorted Array
8.6.
Product of Array Exclude Itself
8.7.
Partition Array
8.8.
First Missing Positive
8.9.
2 Sum
8.10.
3 Sum
8.11.
3 Sum Closest
8.12.
Remove Duplicates from Sorted Array
8.13.
Remove Duplicates from Sorted Array II
8.14.
Merge Sorted Array
8.15.
Merge Sorted Array II
8.16.
Median
8.17.
Partition Array by Odd and Even
8.18.
Kth Largest Element
9.
Binary Search
9.1.
Binary Search
9.2.
Search Insert Position
9.3.
Search for a Range
9.4.
First Bad Version
9.5.
Search a 2D Matrix
9.6.
Search a 2D Matrix II
9.7.
Find Peak Element
9.8.
Search in Rotated Sorted Array
9.9.
Search in Rotated Sorted Array II
9.10.
Find Minimum in Rotated Sorted Array
9.11.
Find Minimum in Rotated Sorted Array II
9.12.
Median of two Sorted Arrays
9.13.
Sqrt x
9.14.
Wood Cut
10.
Math and Bit Manipulation
10.1.
Single Number
10.2.
Single Number II
10.3.
Single Number III
10.4.
O1 Check Power of 2
10.5.
Convert Integer A to Integer B
10.6.
Factorial Trailing Zeroes
10.7.
Unique Binary Search Trees
10.8.
Update Bits
10.9.
Fast Power
10.10.
Hash Function
10.11.
Count 1 in Binary
10.12.
Fibonacci
10.13.
A plus B Problem
10.14.
Print Numbers by Recursion
10.15.
Majority Number
10.16.
Majority Number II
10.17.
Majority Number III
10.18.
Digit Counts
10.19.
Ugly Number
10.20.
Plus One
11.
Linked List
11.1.
Remove Duplicates from Sorted List
11.2.
Remove Duplicates from Sorted List II
11.3.
Remove Duplicates from Unsorted List
11.4.
Partition List
11.5.
Add Two Numbers
11.6.
Two Lists Sum Advanced
11.7.
Remove Nth Node From End of List
11.8.
Linked List Cycle
11.9.
Linked List Cycle II
11.10.
Reverse Linked List
11.11.
Reverse Linked List II
11.12.
Merge Two Sorted Lists
11.13.
Merge k Sorted Lists
11.14.
Reorder List
11.15.
Copy List with Random Pointer
11.16.
Sort List
11.17.
Insertion Sort List
11.18.
Palindrome Linked List
11.19.
Delete Node in the Middle of Singly Linked List
11.20.
LRU Cache
11.21.
Rotate List
11.22.
Swap Nodes in Pairs
11.23.
Remove Linked List Elements
12.
Binary Tree
12.1.
Binary Tree Preorder Traversal
12.2.
Binary Tree Inorder Traversal
12.3.
Binary Tree Postorder Traversal
12.4.
Binary Tree Level Order Traversal
12.5.
Binary Tree Level Order Traversal II
12.6.
Maximum Depth of Binary Tree
12.7.
Balanced Binary Tree
12.8.
Binary Tree Maximum Path Sum
12.9.
Lowest Common Ancestor
12.10.
Invert Binary Tree
12.11.
Diameter of a Binary Tree
12.12.
Construct Binary Tree from Preorder and Inorder Traversal
12.13.
Construct Binary Tree from Inorder and Postorder Traversal
12.14.
Subtree
12.15.
Binary Tree Zigzag Level Order Traversal
12.16.
Binary Tree Serialization
13.
Binary Search Tree
13.1.
Insert Node in a Binary Search Tree
13.2.
Validate Binary Search Tree
13.3.
Search Range in Binary Search Tree
13.4.
Convert Sorted Array to Binary Search Tree
13.5.
Convert Sorted List to Binary Search Tree
13.6.
Binary Search Tree Iterator
14.
Exhaustive Search
14.1.
Subsets
14.2.
Unique Subsets
14.3.
Permutations
14.4.
Unique Permutations
14.5.
Next Permutation
14.6.
Previous Permuation
14.7.
Permutation Index
14.8.
Permutation Index II
14.9.
Permutation Sequence
14.10.
Unique Binary Search Trees II
14.11.
Palindrome Partitioning
14.12.
Combinations
14.13.
Combination Sum
14.14.
Combination Sum II
14.15.
Minimum Depth of Binary Tree
14.16.
Word Search
15.
Dynamic Programming
15.1.
Triangle
15.2.
Backpack
15.3.
Backpack II
15.4.
Minimum Path Sum
15.5.
Unique Paths
15.6.
Unique Paths II
15.7.
Climbing Stairs
15.8.
Jump Game
15.9.
Word Break
15.10.
Longest Increasing Subsequence
15.11.
Palindrome Partitioning II
15.12.
Longest Common Subsequence
15.13.
Edit Distance
15.14.
Jump Game II
15.15.
Best Time to Buy and Sell Stock
15.16.
Best Time to Buy and Sell Stock II
15.17.
Best Time to Buy and Sell Stock III
15.18.
Best Time to Buy and Sell Stock IV
15.19.
Distinct Subsequences
15.20.
Interleaving String
15.21.
Maximum Subarray
15.22.
Maximum Subarray II
15.23.
Longest Increasing Continuous subsequence
15.24.
Longest Increasing Continuous subsequence II
15.25.
Egg Dropping Puzzle
15.26.
Maximal Square
16.
Graph
16.1.
Find the Connected Component in the Undirected Graph
16.2.
Route Between Two Nodes in Graph
16.3.
Topological Sorting
16.4.
Word Ladder
16.5.
Bipartial Graph Part I
17.
Data Structure
17.1.
Implement Queue by Two Stacks
17.2.
Min Stack
17.3.
Sliding Window Maximum
17.4.
Longest Words
17.5.
Heapify
17.6.
Kth Smallest Number in Sorted Matrix
18.
Problem Misc
18.1.
Nuts and Bolts Problem
18.2.
String to Integer
18.3.
Insert Interval
18.4.
Merge Intervals
18.5.
Minimum Subarray
18.6.
Matrix Zigzag Traversal
18.7.
Valid Sudoku
18.8.
Add Binary
18.9.
Reverse Integer
18.10.
Gray Code
18.11.
Find the Missing Number
18.12.
N Queens
18.13.
N Queens II
18.14.
Minimum Window Substring
18.15.
Continuous Subarray Sum
18.16.
Continuous Subarray Sum II
18.17.
Longest Consecutive Sequence
19.
Part III - Contest
20.
Google APAC
20.1.
APAC 2015 Round B
20.1.1.
Problem A. Password Attacker
20.2.
APAC 2016 Round D
20.2.1.
Problem A. Dynamic Grid
21.
Microsoft
21.1.
Microsoft 2015 April
21.1.1.
Problem A. Magic Box
21.1.2.
Problem B. Professor Q's Software
21.1.3.
Problem C. Islands Travel
21.1.4.
Problem D. Recruitment
21.2.
Microsoft 2015 April 2
21.2.1.
Problem A. Lucky Substrings
21.2.2.
Problem B. Numeric Keypad
21.2.3.
Problem C. Spring Outing
21.3.
Microsoft 2015 September 2
21.3.1.
Problem A. Farthest Point
22.
Appendix I Interview and Resume
22.1.
Interview
22.2.
Resume
23.
Appendix II System Design
23.1.
The System Design Process
23.2.
Statistics
23.3.
System Architecture
23.4.
Scalability
Powered by
GitBook
A
A
衬线体
无衬线体
白色
棕褐色
夜间
分享到 Twitter
分享到 Google
分享到 Facebook
分享到 Weibo
分享到 Instapaper
leetcode
改进此页
Search - 搜索
本章主要总结二分搜索相关的题。
能使用二分搜索的前提是数组已排序。
二分查找的使用场景:(1)可转换为find the first/last position of...(2)时间复杂度至少为O(lgn)。
递归和迭代的使用场景:能用迭代就用迭代,特别复杂时采用递归。