LeetCode分类

原始网址


An algorithm problem contains 3 parts: the input, the output and the solution. The input data structures can be an array, string, tree, liked list, matrix, etc. The algorithm used to solve the problem can be dynamic programming, BFS and DFS. It can also be a data structure, such as a heap, stack, hash set, hash map, etc. In this post, the algorithm problems are classified by their input data structure. Under each categories, the problems are tagged with their algorithm or data structure used to solve the problem.

1. Array/String

–Two Pointers–
1) Two SumTwo Sum IITwo Sum III3Sum4Sum3Sum Closest
2) Minimum Size Subarray Sum
3) Remove Duplicates from Sorted Array IIIRemove Element Move Zeroes
4) Container With Most WaterCandy Trapping Rain Water
5) Summary Ranges
6) One Edit Distance
7) Merge Sorted Array
8) Shortest Word DistanceShortest Word Distance IIShortest Word Distance III
9) Intersection of Two ArraysIntersection of Two Arrays II
10) Product of Array Except Self
11) Is Subsequence

–classic array problem–
Kth Largest Element in an Array

–Finding a Number–
Missing Number
Find the duplicate number
First Missing Positive

–Binary Search–
Median of Two Sorted Arrays
Search Insert Position
Find Minimum in Rotated Sorted Array: III
Search for a Range
Guess Number Higher or Lower
First Bad Version
Search in Rotated Array:III
Longest Increasing Subsequence
Russian Doll Envelopes

–Stack–
Evaluate Reverse Polish Notation (Stack)
Valid Parentheses
Longest Valid Parentheses
Valid Palindrome
Min Stack

–Stack–Largest Rectangle–
Largest Rectangle in Histogram
Maximal Rectangle

–Stack–Nested Object–
Mini Parser
Flatten Nested List Iterator
Nested List Weight Sum
Nested List Weight Sum II (HashMap)
Longest Absolute File Path
Decode String

–HashMap–
Valid AnagramGroup Shifted Strings
Palindrome Pairs
Line Reflection

–HashMap–Tracking–
Longest Substring Without Repeating Characters
Longest Substring that contains 2 unique characters [Google]
Substring with Concatenation of All Words
Minimum Window Substring
Longest Substring with At Least K Repeating Characters

–HashSet–
Isomorphic Strings
Longest Consecutive Sequence

–Caching–
Majority Element: III
Increasing Triplet Subsequence, Find Top 2 Largest Elements

–Rotate–
Rotate ArrayReverse Words in a String

–Bucket Sort–
Group Anagrams

–DFS–
Wildcard MatchingRegular Expression Matching
Get Target Using Number List And Arithmetic Operations 
Flip GameFlip Game II
Word PatternWord Pattern II
Scramble String
Remove Invalid Parentheses
Shortest Palindrome

Lexicographical Numbers

–BFS–
Word Ladder (BFS)Word Ladder II (BFS)

–Heap–
Top K Frequent Elements
Meeting Rooms IIMeeting Rooms
Range Addition
Merge k sorted arrays
Merge k Sorted Lists
Rearrange String k Distance Apart

–TreeSet–
Contains Duplicate: IIIIII
Max Sum of Rectangle No Larger Than K
Maximum Sum Of Subarray Close To K

–Track min/max and update result–
H-Index H-Index II

–Stream–(deque/caching/heap/treeset)
Sliding Window Maximum
Moving Average from Data Stream
Find Median from Data Stream
Data Stream as Disjoint Intervals

–Sorting–
Largest Number
Mergesort
Quicksort
Insertion Sort.
Maximum Gap (Bucket Sort)
Sort Colors (Counting Sort)

–Interval–
Merge Intervals
Insert Interval

–Implement data structure–
Implement a Stack Using an Array
Implement Stack using Queues
Implement Queue using Stacks
Implement a Queue using an Array

–Trie–
Implement Trie (Prefix Tree)
Add and Search Word – Data structure design (DFS)

–Segment Tree & Binary Index Tree–
Range Sum Query – Mutable
The Skyline Problem

–Graph–(mainly topological sort)–
Clone Graph
Course Schedule Course Schedule II Minimum Height Trees
Reconstruct Itinerary
Graph Valid Tree

–Ugly Number–
Ugly NumberUgly Number II
Super Ugly Number
Find K Pairs with Smallest Sums

–Maximum subarray–
Maximum Subarray
Maximum Product Subarray

–Word break–
Word Break
Word Break II

–DP–
Palindrome Partitioning
Palindrome Partitioning II 
House RobberIIIII
Jump GameII
Best Time to Buy and Sell Stock IIIII IV 
Dungeon Game 
Minimum Path Sum
Unique Paths
Decode Ways
Coin Change
Perfect Squares

–DP–2D–
Edit Distance
Distinct Subsequences Total
Longest Palindromic Substring
Longest Common Subsequence
Longest Common Substring

–Design data structure with time requirements–
LRU Cache
Insert Delete GetRandom O(1)
Insert Delete GetRandom O(1) – Duplicates allowed
Insert Delete GetMostFrequent O(1)
Design Phone Directory
Design Twitter

–Other dbf/bfs–
Permutations
Permutations II 
Permutation Sequence
Generate Parentheses
Combination Sum (DFS)II (DFS)III (DFS)IV (DP)
Combinations (DFS)
Letter Combinations of a Phone Number (DFS)
Restore IP Addresses
Factor Combinations (DFS)
Subsets
Subsets II

–Random–
Linked List Random Node
Shuffle an Array

–Other–
Triangle
String to Integer
Implement strStr()
ZigZag Conversion
Add Binary 
Length of Last Word
Bulls and Cows 
Longest Common Prefix 
Simplify Path
Compare Version Numbers
Pascal’s Triangle: III
Count and Say
Basic CalculatorBasic Calculator II
Rectangle Area
Reverse Vowels of a String 
Find Peak Element
Integer to English Words
Text Justification 
Gas Station
Self Crossing
Patching Array
Nim Game
Bulb Switcher
Pain Fence
Nested List Weight Sum

2. Matrix

–sorted matrix–
Search a 2D Matrix
Search a 2D Matrix II
Kth Smallest Element in a Sorted Matrix

–queue–
Design Snake Game

–bfs/dfs–
Set Matrix Zeroes
Spiral Matrix
Spiral Matrix II
Rotate Image [Palantir]
Minimum Path Sum (DP)
Unique Paths (DP)
Unique Paths II (DP)
Number of Islands (DFS/BFS)Number of Islands II (Disjoint Set), Number of Connected Components in an Undirected Graph
Surrounded Regions (BFS)
Maximal Square
Word Search (DFS)
Word Search II
Range Sum Query 2D – Immutable
Longest Increasing Path in a Matrix (DFS)
Shortest Distance from All Buildings
Game of Life
Paint HousePaint House II
Sudoku Solver (DFS)Valid Sudoku 
Walls and Gates (DFS/BFS)
Tic-Tac-Toe
Best Meeting Point
Find a Path in a Matrix

3. Linked List

Add Two Numbers
Reorder List
Linked List Cycle
Copy List with Random Pointer
Merge Two Sorted Lists
Odd Even Linked List
Remove Duplicates from Sorted List
Remove Duplicates from Sorted List II
Partition List
Intersection of Two Linked Lists
Remove Linked List Elements
Swap Nodes in Pairs
Reverse Linked ListReverse Linked List II, Print Linked List in Reversed Order
Remove Nth Node From End of List (Fast-Slow Pointers)
Palindrome Linked List
Delete Node in a Linked List
Reverse Nodes in k-Group
Sort List
Plus One Linked List

4. Tree

–traveral–
Binary Tree Traversal: PreorderInorderPostorderLevel OrderLevel Order IIVertical Order

–dfs/bfs–

Invert Binary Tree
Kth Smallest Element in a BST
Binary Tree Longest Consecutive Sequence
Validate Binary Search Tree
Flatten Binary Tree to Linked List
Path Sum (DFS or BFS)
Path Sum II (DFS) 
Construct Binary Tree from Inorder and Postorder Traversal
Construct Binary Tree from Preorder and Inorder Traversal
Convert Sorted Array to Binary Search Tree
Convert Sorted List to Binary Search Tree
Minimum Depth of Binary Tree
Binary Tree Maximum Path Sum *
Balanced Binary Tree
Symmetric Tree
Binary Search Tree Iterator 
Binary Tree Right Side View
Lowest Common Ancestor of a Binary Search Tree
1Lowest Common Ancestor of a Binary Tree
Verify Preorder Serialization of a Binary Tree
Populating Next Right Pointers in Each Node 
Populating Next Right Pointers in Each Node II 
Unique Binary Search Trees (DP)
Unique Binary Search Trees II (DFS)
Sum Root to Leaf Numbers (DFS)
Count Complete Tree Nodes 
Closest Binary Search Tree Value
Binary Tree Paths
Maximum Depth of Binary Tree
Recover Binary Search Tree
Same Tree
Serialize and Deserialize Binary Tree
Inorder Successor in BST
Find Leaves of Binary Tree
Largest BST Subtree

5. Bit Manipulation

Single Number
Single Number II
Maximum Binary Gap
Number of 1 Bits 
Reverse Bits 
Repeated DNA Sequences
Bitwise AND of Numbers Range 
Sum of Two Integers
Counting Bits
Maximum Product of Word Lengths
Gray Code
UTF-8 Validation

6. Math

–power–
Pow(x,n)Power of TwoPower of ThreePower of Four 
Super Pow

–/%–
Reverse Integer
Palindrome Number

Fraction to Recurring Decimal
Excel Sheet Column Number
Excel Sheet Column Title 
Factorial Trailing Zeroes
Happy Number
Count Primes
Plus One
Divide Two Integers
Multiply Strings
Max Points on a Line
Integer Break
Add Digits
Largest Divisible Subset
Count Numbers with Unique Digits


评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值