Skip to content

PaulGuo5/Leetcode-notes

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 
 
 
 
 
 
 
 
 

Repository files navigation

LeetCode solutions

  • As for algorithms, solved mainly in Python 3, and partly in C++ and Java.
  • There are totally 808 solutions in this repo.
  • My leetcode profile: https://leetcode.com/441858734/.

Lists of topics

Leetcode

Leetcode website

Bit Manipulation

NO. Title Solution Note Difficulty Time Space Tag
No.136 Single Number Solution Note Easy O(n) O(1) ---
No.29 Divide Two Integers Solution Note Medium O(n) O(1) ---
No.1356 Sort Integers by The Number of 1 Bits Solution Note Easy O(n) O(n) ---
No.201 Bitwise AND of Numbers Range Solution Note Medium O(n) O(1) ---
No.260 Single Number III Solution Note Medium O(n) O(1) ---
No.421 Maximum XOR of Two Numbers in an Array Solution Note Medium O(n) O(n) Trie

Array

NO. Title Solution Note Difficulty Time Space Tag
No.42 Trapping Rain Water Solution Note Hard O(m) O(1) 2 pointers
No.289 Game of Life Solution Note Medium O(nm) O(1) Bit
No.11 Container With Most Water Solution Note Medium O(n) O(1) 2 pointers
No.560 Subarray Sum Equals K Solution Note Medium O(n) O(n) ---
No.54 Spiral Matrix Solution Note Medium O(n) O(n) ---
No.380 Insert Delete GetRandom O(1) Solution Note Medium O(n) O(n) ---
No.79 Word Search Solution Note Medium O(nm) O(nm) ---
No.78 Subsets Solution Note Medium O(2^n) O(2^n) iterative or dfs
No.90 Subsets II Solution Note Medium O(2^n) O(2^n) iterative or dfs
No.1007 Minimum Domino Rotations For Equal Row Solution Note Medium O(n) O(1) greedy
No.31 Next Permutation Solution Note Medium O(n) O(1) single pointer
No.986 Interval List Intersections Solution Note Medium O(n+m) O(1) 2 pointer2
No.1252 Cells with Odd Values in a Matrix Solution Note Easy O(n^2) O(n) ---
No.1207 Unique Number of Occurrences Solution Note Easy O(n) O(n) ---
No.1243 Array Transformation Solution Note Easy O(n^2) O(n) ---
No.1232 Check If It Is a Straight Line Solution Note Easy O(n) O(n) ---
No.1200 CMinimum Absolute Difference Solution Note Easy O(n) O(n) ---
No.1196 How Many Apples Can You Put into the Basket Solution Note Easy O(n) O(n) ---
No.1184 Distance Between Bus Stops Solution Note Easy O(n) O(1) ---
No.1150 Check If a Number Is Majority Element in a Sorted Array Solution Note Easy O(n) O(n) ---
No.1099 Two Sum Less Than K Solution Note Easy O(n) O(1) 2 pointers
No.1304 Find N Unique Integers Sum up to Zero Solution Note Easy O(n) O(n) ---
No.1287 Element Appearing More Than 25% In Sorted Array Solution Note Easy O(n) O(1) ---
No.759 Employee Free Time Solution Note Hard O(nlogn) O(n) flatten
No.1152 Analyze User Website Visit Pattern Solution Note Hard O(nlogn) O(n) ---
No.55 Jump Game Solution Note Medium O(n) O(1) greedy
No.846 Hand of Straights Solution Note Medium O(n) O(1) try+except
No.1146 Snapshot Array Solution Note Medium O(n) O(n) copy
No.73 Set Matrix Zeroes Solution Note Medium O(n^2) O(n) ---
No.48 Rotate Image Solution Note Medium O(n^2) O(1) ---
No.134 Gas Station Solution Note Medium O(n) O(1) greedy
No.384 Shuffle an Array Solution Note Medium O(n) O(n) ---
No.59 Spiral Matrix II Solution Note Medium O(n^2) O(n^2) ---
No.713 Subarray Product Less Than K Solution Note Medium O(n) O(1) slide window
No.995 Minimum Number of K Consecutive Bit Flips Solution Note Hard O(n) O(n) greedy+slide window
No.243 Shortest Word Distance Solution Note Easy O(n) O(1) ---
No.45 Jump Game II Solution Note Hard O(n) O(n) lcd.1326/lcd.1024
No.1326 Minimum Number of Taps to Open to Water a Garden Solution Note Hard O(n) O(n) lcd.45/lcd.1024
No.1024 Video Stitching Solution Note Medium O(n) O(n) lcd.45/lcd.1326
No.670 Maximum Swap Solution Note Medium O(n) O(n) ---
No.1365 How Many Numbers Are Smaller Than the Current Number Solution Note Easy O(n) O(n) bucket
No.1394 Find Lucky Integer in an Array Solution Note Easy O(n) O(n) ---
No.260 Single Number III Solution Note Medium O(n) O(n) ---
No.1403 Minimum Subsequence in Non-Increasing Order Solution Note Easy O(n) O(n) ---
No.1399 Count Largest Group Solution Note Easy O(n) O(n) ---
No.1389 Create Target Array in the Given Order Solution Note Easy O(n) O(n) ---
No.1385 Find the Distance Value Between Two Arrays Solution Note Easy O(nlogn) O(n) ---
No.1380 Lucky Numbers in a Matrix Solution Note Easy O(nxm) O(n) ---
No.1351 Count Negative Numbers in a Sorted Matrix Solution Note Easy O(n) O(1) ---
No.1346 Check If N and Its Double Exist Solution Note Easy O(n) O(n) ---
No.1332 Remove Palindromic Subsequences Solution Note Easy O(n) O(n) ---
No.992 Subarrays with K Different Integers Solution Note Hard O(n) O(n) slide window
No.406 Queue Reconstruction by Height Solution Note Medium O(n^2) O(n) insert function
No.729 My Calendar I Solution Note Medium O(n) O(n) interval
No.1229 Meeting Scheduler Solution Note Medium O(n) O(1) interval
No.1275 Find Winner on a Tic Tac Toe Game Solution Note Easy O(n^2) O(n) ---
No.1202 Smallest String With Swaps Solution Note Medium O(n) O(nlogn) union find
No.274 H-Index Solution Note Medium O(n) O(1) ---
No.1375 Bulb Switcher III Solution Note Medium O(1) O(1) ---
No.252 Meeting Rooms Solution Note Easy O(nlogn) O(1) interval
No.435 Non-overlapping Intervals Solution Note Medium O(nlogn) O(1) interval
No.18 4Sum Solution Note Medium O(n^3) O(n) ---
No.442 Find All Duplicates in an Array Solution Note Medium O(n) O(1) ---
No.484 Find Permutation Solution Note Medium O(n) O(n) ---
No.969 Pancake Sorting Solution Note Medium O(n^2) O(n) ---
No.835 Image Overlap Solution Note Medium O(n^2) O(n) ---
No.1574 Shortest Subarray to be Removed to Make Array Sorted Solution Note Medium O(n) O(1) 2 pointers
No.56 Merge Intervals Solution Note Medium O(n) O(n) intervals
No.57 Insert Interval Solution Note Hard O(n) O(n) intervals
No.1094 Car Pooling Solution Note Medium O(n) O(n) ---
No.495 Teemo Attacking Solution Note Medium O(n) O(1) intervals
No.41 First Missing Positive Solution Note Hard O(n) O(1) hash index
No.624 Maximum Distance in Arrays Solution Note Easy O(n) O(1) ---
No.917 Reverse Only Letters Solution Note Easy O(n) O(1) 2 pointers
No.1288 Remove Covered Intervals Solution Note Medium O(nlogn) O(1) intervals
No.189 Rotate Array Solution Note Medium O(n) O(1) 2 pointers
No.948 Bag of Tokens Solution Note Medium O(nlogn) O(n) greedy
No.799 Champagne Tower Solution Note Medium O(n^2) O(n) greedy simulation
No.228 Summary Ranges Solution Note Easy O(n) O(n) ---
No.239 Sliding Window Maximum Solution Note Hard O(n) O(n) monotonic deque
No.1395 Count Number of Teams Solution Note Medium O(n^2) O(n) ---
No.1086 High Five Solution Note Easy O(n) O(n) ---
No.163 Missing Ranges Solution Note Easy O(n) O(n) ---
No.334 Increasing Triplet Subsequence Solution Note Medium O(n) O(1) ---
No.611 Valid Triangle Number Solution Note Medium O(n^2) O(n) 2 pointers
No.760 Find Anagram Mappings Solution Note Easy O(n) O(n) ---
No.422 Valid Word Square Solution Note Easy O(n^2) O(1) ---

String

NO. Title Solution Note Difficulty Time Space Tag
No.409 Longest Palindrome Solution Note Easy O(n) O(n) ---
No.5 Longest Palindromic Substring Solution Note Medium O(n^2) O(1) Greedy
No.3 Longest Substring Without Repeating Characters Solution Note Medium O(n) O(n) slide window
No.15 3Sum Solution Note Medium O(n^2) O(1) 2 pointers
No.301 Remove Invalid Parentheses Solution Note Hard O(2^(l+r)) O(n^2) dfs
No.76 Minimum Window Substring Solution Note Hard O(n)) O(n) dfs
No.22 Generate Parentheses Solution Note Medium O(2^n)) O(n) dfs
No.49 Group Anagrams Solution Note Medium O(n)) O(n) ---
No.336 Palindrome Pairs Solution Note Hard O(n^2)) O(n) ---
No.68 Text Justification Solution Note Hard O(n)) O(n) ---
No.17 Letter Combinations of a Phone Number Solution Note Medium O(4^n)) O(4^n+n) dfs
No.468 Validate IP Address Solution Note Medium O(n)) O(n) ---
No.937 Reorder Data in Log Files Solution Note Easy O(n)) O(n) ---
No.91 Decode Ways Solution Note Medium O(n)) O(n) dp
No.609 Find Duplicate File in System Solution Note Medium O(n)) O(n) ---
No.266 Palindrome Permutation Solution Note Easy O(n)) O(n) ---
No.1221 Split a String in Balanced Strings Solution Note Easy O(n)) O(n) ---
No.1189 Maximum Number of Balloons Solution Note Easy O(n)) O(n) ---
No.1165 Single-Row Keyboard Solution Note Easy O(n)) O(n) ---
No.1119 Remove Vowels from a String Solution Note Easy O(n)) O(n) ---
No.1048 Longest String Chain Solution Note Medium O(n^2)) O(n) dfs
No.1271 Hexspeak Solution Note Easy O(n)) O(n) ---
No.227 HBasic Calculator II Solution Note Medium O(n)) O(n) ---
No.567 Permutation in String Solution Note Medium O(n)) O(n) sliding window
No.30 Substring with Concatenation of All Words Solution Note Hard O(n^2)) O(n) sliding window
No.340 Longest Substring with At Most K Distinct Characters Solution Note Hard O(n)) O(1) sliding window
No.1268 Search Suggestions System Solution Note Hard O(nlogn)) O(n) bisect
No.438 Find All Anagrams in a String Solution Note Hard O(n)) O(n) sliding window
No.438 Find All Anagrams in a String Solution Note Hard O(n)) O(n) sliding window
No.271 Encode and Decode Strings Solution Note Medium O(n)) O(n) ---
No.809 Expressive Words Solution Note Medium O(n)) O(1) ---
No.833 Find And Replace in String Solution Note Medium O(n)) O(1) ---
No.1055 Shortest Way to Form String Solution Note Medium O(n)) O(1) ---
No.161 One Edit Distance Solution Note Medium O(n)) O(1) ---
No.161 Word Subsets Solution Note Medium O(n^2)) O(n) ---
No.6 ZigZag Conversion Solution Note Medium O(n)) O(n) ---
No.12 Integer to Roman Solution Note Medium O(n)) O(n) ---
No.293 Flip Game Solution Note Easy O(n)) O(n) ---
No.539 Minimum Time Difference Solution Note Medium O(n)) O(n) ---
No.1374 Generate a String With Characters That Have Odd Counts Solution Note Easy O(n)) O(n) ---
No.1177 Can Make Palindrome from Substring Solution Note Medium O(nx26)) O(nx26) prefix sum
No.1338 Reduce Array Size to The Half Solution Note Medium O(n)) O(n) ---
No.1370 Increasing Decreasing String Solution Note Easy O(n)) O(n) ---
No.1323 Maximum 69 Number Solution Note Easy O(n)) O(n) ---
No.1405 Longest Happy String Solution Note Medium O(n)) O(n) greedy
No.647 Palindromic Substrings Solution Note Medium O(n^2) O(n^2) ---
No.763 Partition Labels Solution Note Medium O(n) O(n) ---
No.524 Longest Word in Dictionary through Deleting Solution Note Medium O(nlogn) O(n) ---
No.316 Remove Duplicate Letters Solution Note Medium O(n) O(n) ---
No.1446 Consecutive Characters Solution Note Easy O(n)) O(1) ---
No.1614 Maximum Nesting Depth of the Parentheses Solution Note Easy O(n)) O(1) ---

Linked List

NO. Title Solution Note Difficulty Time Space Tag
No.82 Remove Duplicates from Sorted List II Solution Note Medium O(n) O(1) ---
No.21 Merge Two Sorted Lists Solution Note Easy O(n) O(1) Dummy node
No.24 Swap Nodes in Pairs Solution Note Medium O(n) O(1) iterative/recursive
No.83 Remove Duplicates from Sorted List Solution Note Easy O(n) O(1) ---
No.160 Intersection of Two Linked Lists Solution Note Easy O(n) O(1) ---
No.203 Remove Linked List Elements Solution Note Easy O(n) O(1) ---
No.237 Delete Node in a Linked List Solution Note Easy O(1) O(1) ---
No.234 Palindrome Linked List Solution Note Easy O(n) O(n) ---
No.206 Reverse Linked List Solution Note Easy O(n) O(1) ---
No.92 Reverse Linked List II Solution Note Medium O(n) O(1) ---
No.2 Add Two Numbers Python/Cpp/Java Note Medium O(n) O(n) ---
No.19 Remove Nth Node From End of List Solution Note Medium O(n) O(1) ---
No.141 Linked List Cycle Solution Note Easy O(n) O(1) fast slow pointers
No.142 Linked List Cycle II Solution Note Easy O(n) O(1) fast slow pointers
No.23 Merge k Sorted Lists Solution Note Easy O(nlogn) O(nk) ---
No.61 Rotate List Solution Note Medium O(n) O(1) ---
No.138 Copy List with Random Pointer Solution Note Medium O(n) O(n) ---
No.86 Partition List Solution Note Medium O(n) O(n) ---
No.143 Reorder List Solution Note Medium O(n) O(n) ---
No.109 Convert Sorted List to Binary Search Tree Solution Note Medium O(nlogn) O(n) recursion
No.328 Odd Even Linked List Solution Note Medium O(n) O(1) ---
No.369 Plus One Linked List Solution Note Medium O(n) O(1) ---
No.430 Flatten a Multilevel Doubly Linked List Solution Note Medium O(n) O(1) ---
No.445 Add Two Numbers II Solution Note Medium O(n) O(1) ---
No.708 Insert into a Sorted Circular Linked List Solution Note Medium O(n) O(1) ---
No.725 Split Linked List in Parts Solution Note Medium O(n) O(n) ---
No.817 Linked List Components Solution Note Medium O(n) O(1) ---
No.1019 Next Greater Node In Linked List Solution Note Medium O(n) O(n) stack
No.1171 Remove Zero Sum Consecutive Nodes from Linked List Solution Note Medium O(n) O(n) ---
No.1290 Convert Binary Number in a Linked List to Integer Solution Note Medium O(n) O(n) ---
No.0025 Reverse Nodes in k-Group Solution Note Medium O(n) O(1) ---

Stack

NO. Title Solution Note Difficulty Time Space Tag
No.56 Merge Intervals Solution Note Medium O(n) O(n) ---
No.20 Valid Parentheses Solution Note Easy O(n) O(n) ---
No.224 Basic Calculator Solution Note Hard O(n) O(n) ---
No.739 Daily Temperatures Solution Note Medium O(n) O(n) ---
No.456 132 Pattern Solution Note Medium O(n) O(n) ---
No.32 Longest Valid Parentheses Solution Note Hard O(n) O(n) ---
No.582 Kill Process Solution Note Medium O(n) O(n) ---
No.716 Max Stack Solution Note Easy O(n) O(n) ---
No.636 Exclusive Time of Functions Solution Note Medium O(n) O(n) ---
No.678 Valid Parenthesis String Solution Note Medium O(n) O(n) ---
No.1130 Minimum Cost Tree From Leaf Values Solution Note Medium O(n) O(n) ---
No.735 Asteroid Collision Solution Note Medium O(n) O(n) ---
No.503 Next Greater Element II Solution Note Medium O(n) O(n) monotonous stack
No.901 Online Stock Span Solution Note Medium O(n) O(n) monotonous stack
No.84 Largest Rectangle in Histogram Solution Note Hard O(n) O(n) monotonous stack
No.1249 Minimum Remove to Make Valid Parentheses Solution Note Medium O(n) O(n) ---
No.1209 Remove All Adjacent Duplicates in String II Solution Note Medium O(n) O(n) ---

Queue

NO. Title Solution Note Difficulty Time Space Tag
No.346 Moving Average from Data Stream Solution Note Easy O(n) O(n) ---
No.127 Word Ladder Solution Note Medium O(nlogn) O(n) bfs
No.126 Word Ladder II Solution Note Hard O(nlogn) O(n) bfs/dfs
No.743 Network Delay Time Solution Note Medium O(n) O(n) graph+heap/queue
No.752 Open the Lock Solution Note Medium O(8*10000) O(10000) bfs deque
No.1197 Minimum Knight Moves Solution Note Medium O(n) O(n) bfs deque
No.133 Clone Graph Solution Note Medium O(n) O(n) bfs deque
No.773 Sliding Puzzle Solution Note Hard O(n) O(n) bfs deque
No.286 Walls and Gates Solution Note Medium O(n) O(n) bfs deque
No.1236 Web Crawler Solution Note Medium O(n) O(n) bfs deque

Search

NO. Title Solution Note Difficulty Time Space Tag
No.247 Strobogrammatic Number II Solution Note Medium O(2^n) O(n) dfs/bottom-up/top-down
No.39 Combination Sum Solution Note Medium O(2^n) O(n) dfs
No.40 Combination Sum II Solution Note Medium O(2^n) O(n) dfs
No.339 Nested List Weight Sum Solution Note Easy O(n) O(1) ---
No.216 Combination Sum III Solution Note Medium O(2^n) O(n) dfs
No.967 Numbers With Same Consecutive Differences Solution Note Medium O(2^n) O(n) dfs
No.490 The Maze Solution Note Medium O(mn) O(mn) bfs dfs
No.505 The Maze II Solution Note Medium O(mnmax(m,n)) O(mn) bfs dfs
No.499 The Maze III Solution Note Hard O(mnmax(m,n)) O(mn) bfs
No.489 Robot Room Cleaner Solution Note Hard O(n) O(n) dfs
No.1490 Clone N-ary Tree Solution Note Medium O(n) O(n) clone bfs/dfs
No.133 Clone Graph Solution Note Medium O(n) O(n) clone bfs
No.1485 Clone Binary Tree With Random Pointer Solution Note Medium O(n) O(n) clone bfs/dfs
No.138 Copy List with Random Pointer Solution Note Medium O(n) O(n) clone bfs
No.351 Android Unlock Patterns Solution Note Medium O(n) O(n) dfs top-down bottom-up
No.695 Max Area of Island Solution Note Medium O(n) O(n) dfs bfs
No.733 Flood Fill Solution Note Easy O(n) O(n) dfs bfs
No.1162 As Far from Land as Possible Solution Note Medium O(n) O(n) bfs
No.827 Making A Large Island Solution Note Easy O(n^2) O(n^2) dfs
No.1291 Sequential Digits Solution Note Medium O(nlogn) O(n) dfs
No.425 Word Squares Solution Note Hard O(n) O(n) trie bfs
No.847 Shortest Path Visiting All Nodes Solution Note Hard O(nx2^n) O(nx2^n) bfs
No.433 Minimum Genetic Mutation Solution Note Medium O(n) O(n) bfs
No.934 Shortest Bridge Solution Note Medium O(n) O(n) dfs+bfs
No.529 Minesweeper Solution Note Medium O(n) O(1) dfs
No.996 Number of Squareful Arrays Solution Note Hard O(n) O(1) permutation dfs
No.818 Race Car Solution Note Hard O(2^n) O(n) bfs

Binary Search

NO. Title Solution Note Difficulty Time Space Tag
No.4 Median of Two Sorted Arrays Solution Note Hard O(log(m+n)) O(n) ---
No.33 Search in Rotated Sorted Array Solution Note Medium O(log(n)) O(1) ---
No.34 Find First and Last Position of Element in Sorted Array Solution Note Medium O(log(n)) O(1) ---
No.240 Search a 2D Matrix II Solution Note Medium O(log(n)) O(1) ---
No.1231 Divide Chocolate Solution Note Medium O(log(n)) O(1) ---
No.1011 Capacity To Ship Packages Within D Days Solution Note Medium O(log(n)) O(1) ---
No.1283 Find the Smallest Divisor Given a Threshold Solution Note Medium O(log(n)) O(1) ---
No.875 Koko Eating Bananas Solution Note Medium O(log(n)) O(1) ---
No.774 Minimize Max Distance to Gas Station Solution Note Hard O(log(n)) O(1) ---
No.1044 Longest Duplicate Substring Solution Note Hard O(log(n)) O(n) Rabin-karp
No.528 Random Pick with Weight Solution Note Medium O(log(n)) O(n) random
No.981 Time Based Key-Value Store Solution Note Medium O(log(n)) O(n) bisect
No.981 Time Based Key-Value Store Solution Note Medium O(log(n)) O(n) bisect
No.1170 Compare Strings by Frequency of the Smallest Character Solution Note Medium O(log(n)) O(n) bisect
No.16 3Sum Closest Solution Note Medium O(n^2) O(n) ---
No.540 Single Element in a Sorted Array Solution Note Medium O(log(n)) O(1) ---
No.74 Search a 2D Matrix Solution Note Medium O(log(n)) O(1) ---
No.702 Search in a Sorted Array of Unknown Size Solution Note Medium O(log(n)) O(1) ---
No.275 H-Index II Solution Note Medium O(log(n)) O(1) ---
No.34 Find First and Last Position of Element in Sorted Array Solution Note Medium O(n) O(1) ---
No.81 Search in Rotated Sorted Array II Solution Note Medium O(logn) O(1) ---
No.497 Random Point in Non-overlapping Rectangles Solution Note Medium O(n), O(logn) O(n) math(random)+binary search
No.436 Find Right Interval Solution Note Medium O(logn) O(n) ---
No.1533 Find the Index of the Large Integer Solution Note Medium O(nlogn) O(1) ---
No.1300 Sum of Mutated Array Closest to Target Solution Note Medium O(nlogn) O(n) prefix sum + binary search
No.1060 Missing Element in Sorted Array Solution Note Medium O(nlogn) O(1) binary search
No.1235 Maximum Profit in Job Scheduling Solution Note Hard O(nlogn) O(n) binary search + dynamic programming
No.431 Encode N-ary Tree to Binary Tree Solution Note Hard O(n) O(n) ---
No.1482 Minimum Number of Days to Make m Bouquets Solution Note Hard O(nlog(maxA)) O(1) ---
No.1095 Find in Mountain Array Solution Note Hard O(logn) O(1) ---

Binary Tree

NO. Title Solution Note Difficulty Time Space Tag
No.226 Invert Binary Tree Solution Note Easy O(logn) O(n) ---
No.538 Convert BST to Greater Tree Solution Note Easy O(logn) O(n) ---
No.543 Diameter of Binary Tree Solution Note Easy O(logn) O(n) ---
No.687 Longest Univalue Path Solution Note Easy O(logn) O(n) ---
No.897 Increasing Order Search Tree Solution Note Easy O(n) O(n) ---
No.617 Merge Two Binary Trees Solution Note Easy O(n) O(n) ---
No.606 Construct String from Binary Tree Solution Note Easy O(n) O(n) ---
No.572 Subtree of Another Tree Solution Note Easy O(n) O(n) ---
No.563 Binary Tree Tilt Solution Note Easy O(n) O(n) ---
No.94 Binary Tree Inorder Traversal Solution Note Medium O(n) O(n) ---
No.112 Path Sum Solution Note Easy O(n) O(n) ---
No.257 Binary Tree Paths Solution Note Easy O(n) O(n) ---
No.701 Insert into a Binary Search Tree Solution Note Medium O(logn) O(n) ---
No.1008 Construct Binary Search Tree from Preorder Traversal Solution Note Medium O(logn) O(n) ---
No.144 Binary Tree Preorder Traversal Solution Note Medium O(n) O(n) ---
No.814 Binary Tree Preorder Traversal Solution Note Medium O(n) O(1) ---
No.145 Binary Tree Postorder Traversal Solution Note Medium O(n) O(n) ---
No.102 Binary Tree Level Order Traversal Solution Note Medium O(n) O(n) ---
No.105 Construct Binary Tree from Preorder and Inorder Traversal Solution Note Medium O(n) O(n) ---
No.106 Construct Binary Tree from Inorder and Postorder Traversal Solution Note Medium O(n) O(n) ---
No.116 Populating Next Right Pointers in Each Node Solution Note Medium O(n) O(n) ---
No.117 Populating Next Right Pointers in Each Node II Solution Note Medium O(n) O(n) ---
No.652 Find Duplicate Subtrees Solution Note Medium O(n^2) O(n)^2 ---
No.104 Maximum Depth of Binary Tree Solution Note Medium O(n) O(n) ---
No.655 Print Binary Tree Solution Note Medium O(n) O(n) dfs/binary search
No.297 Serialize and Deserialize Binary Tree Solution Note Hard O(n) O(n) dfs/iter()/dequeue()
No.428 Serialize and Deserialize N-ary Tree Solution Note Hard O(n) O(n) dfs/dequeue()
No.124 Binary Tree Maximum Path Sum Solution Note Hard O(n) O(n) ---
No.449 Serialize and Deserialize BST Solution Note Medium O(n) O(n) ---
No.103 Binary Tree Zigzag Level Order Traversal Solution Note Medium O(n) O(n) level traversal
No.119 Binary Tree Right Side View Solution Note Medium O(n) O(n) level traversal
No.426 Convert Binary Search Tree to Sorted Doubly Linked List Solution Note Medium O(n) O(n) inoder/mode
No.863 All Nodes Distance K in Binary Tree Solution Note Medium O(n) O(n) parent node/dfs
No.96 Unique Binary Search Trees Solution Note Medium O(n^2) O(n) dp
No.987 Vertical Order Traversal of a Binary Tree Solution Note Medium O(n) O(n) sort dict/map
No.222 Count Complete Tree Nodes Solution Note Medium O(logn) O(1) binary search
No.450 Delete Node in a BST Solution Note Medium O(h) O(1) recursion
No.99 Recover Binary Search Tree Solution Note Hard O(n) O(n) ---
No.114 Flatten Binary Tree to Linked List Solution Note Medium O(n) O(1) recursion
No.427 Construct Quad Tree Solution Note Medium O(n) O(n) dfs
No.1110 Delete Nodes And Return Forest Solution Note Medium O(n) O( d
No.0889 Construct Binary Tree from Preorder and Postorder Traversal Solution Note Medium O(nlogn) O(n) recursion
No.545 Boundary of Binary Tree Solution Note Medium O(nlogn) O(n) recursion
No.298 Binary Tree Longest Consecutive Sequence Solution Note Medium O(n) O(1) ---
No.951 Flip Equivalent Binary Trees Solution Note Medium O(n) O(1) ---
No.1145 Binary Tree Coloring Game Solution Note Medium O(n) O(1) ---
No.250 Count Univalue Subtrees Solution Note Medium O(n) O(1) ---
No.1038 Binary Search Tree to Greater Sum Tree Solution Note Medium O(n) O(1) ---
No.1214 Two Sum BSTs Solution Note Medium O(n) O(n) ---
No.654 Maximum Binary Tree Solution Note Medium O(n) O(1) ---
No.314 Binary Tree Vertical Order Traversal Solution Note Medium O(n) O(n) queue
No.129 Sum Root to Leaf Numbers Solution Note Medium O(n*m) O(n) ---
No.1302 Deepest Leaves Sum Solution Note Medium O(n) O(1) traversal
No.872 Leaf-Similar Trees Solution Note easy O(n) O(n) collecting nodes
No.1325 Delete Leaves With a Given Value Solution Note Medium O(n) O(1) ---
No.113 Path Sum II Solution Note Medium O(n) O(n) ---
No.666 Path Sum IV Solution Note Medium O(n) O(n) ---
No.508 Most Frequent Subtree Sum Solution Note Medium O(n) O(n) ---
No.968 Binary Tree Cameras Solution Note Hard O(n) O(1) dfs + Bottom-up
No.337 House Robber III Solution Note Medium O(n) O(1) dfs + Bottom-up
No.979 Distribute Coins in Binary Tree Solution Note Medium O(n) O(1) dfs + Bottom-up
No.1120 Maximum Average Subtree Solution Note Medium O(n) O(n) Bottom-up dfs
No.366 Find Leaves of Binary Tree Solution Note Medium O(n) O(n) dfs + Bottom-up
No.1367 Linked List in Binary Tree Solution Note Medium O(n) O(n) Bottom-up dfs
No.958 Check Completeness of a Binary Tree Solution Note Medium O(n) O(n) bfs, level traversal
No.1026 Maximum Difference Between Node and Ancestor Solution Note Medium O(n) O(n) Bottom-up dfs
No.1457 Pseudo-Palindromic Paths in a Binary Tree Solution Note Medium O(n) O(h) dfs
No.1104 Path In Zigzag Labelled Binary Tree cpp/python Note Medium O(logn) O(n) ---

Hash Table

NO. Title Solution Note Difficulty Time Space Tag
No.359 Logger Rate Limiter Solution Note Easy O(n) O(n) ---
No.706 Design HashMap Solution Note Easy O(n) O(n) ---
No.36 Valid Sudoku Solution Note Medium O(n^2) O(n) ---
No.939 Minimum Area Rectangle Solution Note Medium O(n^2) O(n) ---
No.187 Repeated DNA Sequences Solution Note Medium O(n) O(n) ---
No.676 Implement Magic Dictionary Solution Note Medium O(n*26) O(n) ---
No.525 Contiguous Array Solution Note Medium O(n) O(n) ---
No.249 Group Shifted Strings Solution Note Medium O(n) O(n) ---
No.128 Longest Consecutive Sequence Solution Note Hard O(n) O(n) ---
No.170 Two Sum III - Data structure design Solution Note Easy O(n) O(n) ---
No.454 4Sum II Solution Note Medium O(n^2) O(n) ---
No.1169 Invalid Transactions cpp Note/python Note Medium O(n^2) O(n)
No.451 Sort Characters By Frequency Python/Cpp Note Medium O(n) O(n) ---

Sort

NO. Title Solution Note Difficulty Time Space Tag
No.973 K Closest Points to Origin Solution Note Medium O(n) O(n) ---
No.295 Find Median from Data Stream Solution Note Hard O(n) O(n) ---
No.692 Top K Frequent Words Solution Note Medium O(nlogn) O(n) ---
No.1057 Campus Bikes Solution Note Medium O(n^2) O(n) ---
No.912 Sort an Array Solution Note Medium --- --- sortings method summary
No.280 Wiggle Sort Solution Note Medium O(nlogn) O(1) ---
No.324 Wiggle Sort II Solution Note Medium O(nlogn) O(1) ---
No.179 Largest Number Solution Note Medium O(nlogn) O(n) merge sort
No.147 Insertion Sort List Solution Note Medium O(n) O(1) insertion sort
No.452 Minimum Number of Arrows to Burst Balloons Solution Note Medium O(nlogn) O(1) ---

Heap

NO. Title Solution Note Difficulty Time Space Tag
No.253 Meeting Rooms II Solution Note Medium O(nlogn) O(n) heapq
No.1167 Minimum Cost to Connect Sticks Solution Note Medium O(nlogn) O(n) heapq
No.743 Network Delay Time Solution Note Medium O(n) O(n) graph+heap/queue
No.373 Find K Pairs with Smallest Sums Solution Note Medium O(nlogn) O(n) heapq
No.378 Kth Smallest Element in a Sorted Matrix Solution Note Medium O(nlogn) O(n) heapq
No.295 Find Median from Data Stream Solution Note Hard O(nlogn) O(n) heapq
No.703 Kth Largest Element in a Stream Solution Note Easy O(nlogn) O(n) heapq
No.786 K-th Smallest Prime Fraction Solution Note Hard O(nlogn) O(n) heapq
No.767 Reorganize String Solution Note Medium O(nlogn) O(n) heapq
No.1642 Furthest Building You Can Reach Solution Note Medium O(nlogn) O(n) priority queue

Binary Search Tree

NO. Title Solution Note Difficulty Time Space Tag
No.776 Split BST Solution Note Medium O(log(n)) O(1) ---
No.230 Kth Smallest Element in a BST Solution Note Medium O(n) O(1) ---
No.285 Inorder Successor in BST Solution Note Medium O(n) O(1) ---
No.333 Largest BST Subtree Solution Note Medium O(nlogn) O(1) ---
No.270 Closest Binary Search Tree Value Solution Note Easy O(nlogn) O(1) ---
No.1382 Balance a Binary Search Tree Python/Java Note Medium O(n) O(n) AVL
No.1305 All Elements in Two Binary Search Trees Solution Note Medium O(n) O(n) inorder + merge sort
No.501 Find Mode in Binary Search Tree Solution Note Easy O(n) O(1) inorder

Math

NO. Title Solution Note Difficulty Time Space Tag
No.7 Reverse Integer Solution Note Easy O(n) O(1) ---
No.1228 Missing Number In Arithmetic Progression Solution Note Easy O(n) O(1) ---
No.1134 Armstrong Number Solution Note Easy O(n) O(1) ---
No.1281 Subtract the Product and Sum of Digits of an Integer Solution Note Easy O(n) O(1) ---
No.957 Prison Cells After N Days Solution Note Medium O(n) O(n) mode
No.273 Integer to English Words Solution Note Hard O(n) O(1) ---
No.1056 Confusing Number Solution Note Easy O(n) O(1) ---
No.246 Strobogrammatic Number Solution Note Easy O(n) O(1) ---
No.1088 Confusing Number II Solution Note Hard O(nlogn) O(1) ---
No.247 Strobogrammatic Number II Solution Note Medium O(n) O(n) recursion
No.659 Split Array into Consecutive Subsequences Solution Note Medium O(n) O(n) greedy
No.465 Optimal Account Balancing Solution Note Hard O(nlogn) O(n) dfs
No.794 Valid Tic-Tac-Toe State Solution Note Medium O(n) O(n) ---
No.866 Prime Palindrome Solution Note Medium O(n) O(n) ---
No.166 Fraction to Recurring Decimal Solution Note Medium O(n) O(n) ---
No.282 Expression Add Operators Solution Note Hard O(4^n) O(n) dfs
No.43 Multiply Strings Solution Note Medium O(n^2) O(n) ---
No.498 Diagonal Traverse Solution Note Medium O(n*m) O(n*m) ---
No.398 Random Pick Index Solution Note Medium O(n) O(n) Reservoir Sampling
No.382 Linked List Random Node Solution Note Medium O(n) O(1) Reservoir Sampling
No.1342 Number of Steps to Reduce a Number to Zero Solution Note Easy O(n) O(1) ---
No.1317 Convert Integer to the Sum of Two No-Zero Integers Solution Note Easy O(n) O(n) ---
No.1413 Minimum Value to Get Positive Step by Step Sum Solution Note Easy O(n) O(1) prefix sum
No.470 Implement Rand10() Using Rand7() Solution Note Medium O(1) O(1) random
No.593 Valid Square Solution Note Medium O(1) O(1) ---
No.150 Evaluate Reverse Polish Notation Solution Note Medium O(n) O(n) ---
No.640 Solve the Equation Solution Note Medium O(n) O(1) ---
No.1360 Number of Days Between Two Dates Solution Note Easy O(n) O(n) ---
No.1031 Maximum Sum of Two Non-Overlapping Subarrays Solution Note Medium O(n) O(n) prefix sum
No.368 Largest Divisible Subset Solution Note Medium O(n^2) O(n) ---
No.60 Permutation Sequence Solution Note Medium O(n) O(n) ---
No.1344 Angle Between Hands of a Clock Solution Note Medium O(1) O(1) ---
No.556 Next Greater Element III Solution Note Medium O(n) O(n) ---
No.229 Majority Element II Solution Note Medium O(n) O(1) ---
No.829 Consecutive Numbers Sum Solution Note Hard O(n**0.5) O(1) ---
No.497 Random Point in Non-overlapping Rectangles Solution Note Medium O(n), O(logn) O(n) math(random)+binary search
No.220 Contains Duplicate III Solution Note Medium O(n) O(n) ordered dict
No.1237 Find Positive Integer Solution for a Given Equation Solution Note Easy O(n) O(n) 2 pointers
No.855 Exam Room Solution Note Medium O(n) O(n) bisect.insort
No.1041 Robot Bounded In Circle Solution Note Medium O(n) O(1) ---
No.775 Global and Local Inversions Solution Note Medium O(n) O(1) ---
No.1217 Minimum Cost to Move Chips to The Same Position Solution Note Easy O(n) O(1) ---
No.1492 The kth Factor of n Solution Note Medium O(n) O(1) ---

Graph

NO. Title Solution Note Difficulty Time Space Tag
No.200 Number of Islands Solution Note Medium O(mn) O(n) dfs bfs
No.332 Reconstruct Itinerary Solution Note Medium O(nlogn) O(n) dfs
No.399 Evaluate Division Solution Note Medium O(n) O(n) dfs
No.1192 Critical Connections in a Network Solution Note Hard O(n) O(n) dfs/Tarjan
No.694 Number of Distinct Islands Solution Note Medium O(nlogn) O(n) dfs
No.1102 Path With Maximum Minimum Value Solution Note Medium O(nlogn) O(n) heap
No.207 Course Schedule Solution Note Medium O(n) O(n) topological sorting
No.743 Network Delay Time Solution Note Medium O(n) O(n) graph+heap/queue
No.130 Surrounded Regions Solution Note Medium O(n^2) O(n) dfs
No.210 Course Schedule II Solution Note Medium O(n) O(n) topological sorting
No.269 Alien Dictionary Solution Note Hard O(n) O(n) bfs
No.684 Redundant Connection Python/Cpp Note Medium O(n^2)/O(n^2)/O(n) O(n) bfs/dfs/Union find
No.787 Cheapest Flights Within K Stops Solution Note Medium O(m+nlogn) O(n) Dijkstra+heap
No.417 Pacific Atlantic Water Flow Solution Note Medium O(logn) O(n) dfs/bfs
No.547 Friend Circles Solution Note Medium O(n) O(n) dfs
No.1319 Number of Operations to Make Network Connected Solution Note Medium O(n) O(n) Union find
No.547 Sentence Similarity II Solution Note Medium O(nlogn) O(n) dfs
No.909 Snakes and Ladders Solution Note Medium O(n^2) O(n^2) bfs
No.841 Keys and Rooms Solution Note Medium O(n^2) O(n^2) bfs/dfs
No.542 01 Matrix Solution Note Medium O(n^2) O(n^2) bfs
No.721 Accounts Merge Solution Note Medium O(n) O(n^2) dfs
No.261 Graph Valid Tree Solution Note Medium O(n^2) O(n) union find
No.323 Number of Connected Components in an Undirected Graph Solution Note Medium O(n^2) O(n) union find
No.959 Regions Cut By Slashes Solution Note Medium O(n^2) O(n^2) union find
No.1135 Connecting Cities With Minimum Cost Solution Note Medium O(nlogn) O(n) union find
No.990 Satisfiability of Equality Equations Solution Note Medium O(nlogn) O(n) union find
No.1101 The Earliest Moment When Everyone Become Friends Solution Note Medium O(nlogn) O(n) union find
No.1061 Lexicographically Smallest Equivalent String Solution Note Medium O(nlogn) O(n) union find
No.310 Minimum Height Trees Solution Note Medium O(n^2) O(n) ---
No.1245 Minimum Height Trees Solution Note Medium O(n) O(n) dfs/bfs
No.1162 As Far from Land as Possible Solution Note Medium O(n) O(n) bfs
No.802 Find Eventual Safe States Solution Note Medium O(n) O(n) topological sorting
No.1091 Shortest Path in Binary Matrix Solution Note Medium O(n) O(n) bfs
No.797 All Paths From Source to Target Solution Note Medium O(n+v) O(n) ---
No.952 Largest Component Size by Common Factor Solution Note Hard O(n) O(n) union find
No.133 Clone Graph Solution Note Medium O(n) O(n) bfs deque (queue + hashtable)
No.138 Copy List with Random Pointer Solution Note Medium O(n) O(n) clone bfs (queue + hashtable)
No.841 Keys and Rooms Solution Note Medium O(V+E) O(V) dfs bfs
No.1202 Smallest String With Swaps Solution Note Medium O(nlogn) O(n) union find
No.785 Is Graph Bipartite? Cpp Note Medium O(V+E) O(V) bfs,bipartition,graph coloring
No.1129 Shortest Path with Alternating Colors Solution Note Medium O(n) O(n) bfs
No.1334 Find the City With the Smallest Number of Neighbors at a Threshold Distance Solution Note Medium O(n^3) O(n^2) Floyd–Warshall algorithm

Backtracking

NO. Title Solution Note Difficulty Time Space Tag
No.46 Permutations Solution Note Medium O(n!) O(n!) ---
No.47 Permutations II Solution Note Medium O(n!) O(n!) ---
No.1088 Confusing Number II Solution Note Hard O(nlogn) O(1) ---
No.212 Word Search II Solution Note Hard O(sum(l)+4^max(l)) O(n) TrieNode
No.980 Unique Paths III Solution Note Hard O(4^mn) O(m*n) dfs
No.267 Palindrome Permutation II Solution Note Medium O(n^2) O(n) ---
No.1219 Path with Maximum Gold Solution Note Medium O(n^2) O(n) dfs
No.131 Palindrome Partitioning Solution Note Medium O(n!) O(n) ---
No.37 Sudoku Solver Python/Cpp Note Hard O(nlogn) O(n) ---
No.51 N-Queens Solution Note Hard O(n!) O(n) ---
No.294 Flip Game II Solution Note Medium O(n) O(n) memo/min-max
No.464 Can I Win Solution Note Medium O(2^n) O(2^n) memo
No.698 Partition to K Equal Sum Subsets Solution Note Medium O(n!) O(n) ---
No.676 Implement Magic Dictionary Solution Note Medium O(n) O(n) TrieNode
No.1233 Remove Sub-Folders from the Filesystem Solution Note Medium O(nlogn) O(n) TrieNode
No.93 Restore IP Addresses Solution Note Medium O(nlogn) O(n) ---
No.473 Matchsticks to Square Solution Note Medium O(nlogn) O(n) ---
No.95 Unique Binary Search Trees II Solution Note Medium O(3^n) O(3^n) ---
No.77 Combinations Solution Note Medium O(nlogn) O(n) ---
No.425 Word Squares Solution Note Hard O(n) O(n) trie bfs

Dynamic Programming

NO. Title Solution Note Difficulty Time Space Tag
No.53 Maximum Subarray Solution Note Medium O(n) O(n) ---
No.121 Best Time to Buy and Sell Stock Solution Note Easy O(n) O(1) ---
No.10 Regular Expression Matching Solution Note Hard O(n*m) O(n*m) ---
No.96 Unique Binary Search Trees Solution Note Medium O(n^2) O(n) tree
No.91 Decode Ways Solution Note Medium O(n)) O(n) dp
No.1048 Longest String Chain Solution Note Medium O(nlogn)) O(n) dp
No.139 Word Break Solution Note Medium O(n^3)) O(n) ---
No.472 Concatenated Words Solution Note Hard O(n^3)) O(n) ---
No.727 Minimum Window Subsequence Solution Note Hard O(n^2)) O(n) ---
No.552 Student Attendance Record II Solution Note Hard O(n)) O(n) ---
No.239 Sliding Window Maximum Solution Note Hard O(n)) O(1) ---
No.140 Word Break II Solution Note Hard O(nlogn)) O(n) dfs
No.62 Unique Paths Solution Note Hard O(n^2)) O(n) ---
No.63 Unique Paths II Solution Note Hard O(n^2)) O(n) ---
No.1000 Minimum Cost to Merge Stones Solution Note Hard O(N^3/K)) O(KN^2) functools.lru_cache
No.279 Perfect Squares Solution Note Medium O(n^2)) O(n) partition dp
No.221 Maximal Square Solution Note Medium O(n^2)) O(n) ---
No.801 Minimum Swaps To Make Sequences Increasing Solution Note Medium O(n)) O(n) ---
No.877 Stone Game Solution Note Medium O(n^2)) O(n^2) ---
No.486 Predict the Winner Solution Note Medium O(n^2)) O(n^2) ---
No.5 Longest Palindromic Substring Solution Note Medium O(n^2) O(n^2) ---
No.312 Burst Balloons Solution Note Hard O(n^3) O(n^2) ---
No.338 Counting Bits Solution Note Hard O(n) O(n) ---
No.494 Target Sum Solution Note Medium O(n*m) O(n) ---
No.64 Minimum Path Sum Solution Note Medium O(n^2) O(n^2) ---
No.1143 Longest Common Subsequence Solution Note Medium O(n^2) O(n^2) ---
No.300 Longest Increasing Subsequence Solution Note Easy O(n^2) O(n) ---
No.673 Number of Longest Increasing Subsequence Solution Note Medium O(n^2) O(n^2) ---
No.72 Edit Distance Solution Note Hard O(n^2)) O(n^2) ---
No.416 Partition Equal Subset Sum Solution Note Medium O(n^2) O(n^2) ---
No.689 Maximum Sum of 3 Non-Overlapping Subarrays Solution Note Hard O(n) O(n) ---
No.152 Maximum Product Subarray Solution Note Medium O(n) O(n) ---
No.516 Longest Palindromic Subsequence Solution Note Medium O(n^2) O(n^2) ---
No.730 Count Different Palindromic Subsequences Solution Note Hard O(n^2) O(n^2) ---
No.1027 Longest Arithmetic Sequence Solution Note Hard O(n**2)) O(n) ---
No.1223 Dice Roll Simulation Solution Note Medium O(n)) O(n) ---
No.375 Guess Number Higher or Lower II Solution Note Medium O(n^2) O(n^2) min-max
No.740 Delete and Earn Solution Note Medium O(n) O(n) min-max
No.741 Cherry Pickup Solution Note Hard O(n^3) O(n) memo
No.647 Palindromic Substrings Solution Note Medium O(n^2) O(n^2) ---
No.518 Coin Change 2 Solution Note Medium O(n*m) O(n) combination-377
No.377 Combination Sum IV Solution Note Medium O(n*m) O(n) permutation-518
No.983 Minimum Cost For Tickets Solution Note Medium O(n) O(n) similar-322
No.1155 Number of Dice Rolls With Target Sum Solution Note Medium O(n^3) O(n^2) ---
No.978 Longest Turbulent Subarray Solution Note Medium O(n) O(n) ---
No.256 Paint House Solution Note Easy O(n) O(1) ---
No.120 Triangle Solution Note Medium O(n) O(1) ---
No.1139 Largest 1-Bordered Square Solution Note Medium O(n^3) O(n^2) ---
No.688 Knight Probability in Chessboard Solution Note Medium O(n^3) O(n^2) ---
No.174 Dungeon Game Solution Note Hard O(n^2) O(n^2) ---
No.304 Range Sum Query 2D - Immutable Solution Note Medium O(n^2) O(n^2) ---
No.361 Bomb Enemy Solution Note Medium O(n^2) O(n^2) ---
No.265 Paint House II Solution Note Hard O(nk**2) and O(nk) O(1) ---
No.276 Paint Fence Solution Note Easy O(n) O(1) ---
No.887 Super Egg Drop Solution Note Hard O(knm) O(nm) ---
No.198 House Robber Solution Note Easy O(n) O(n) and O(1) ---
No.213 House Robber II Solution Note Medium O(n) O(n) and O(1) ---
No.123 Best Time to Buy and Sell Stock III Solution Note Hard O(n*5) O(n) ---
No.188 Best Time to Buy and Sell Stock IV Solution Note Hard O(nk) O(nk) ---
No.132 Palindrome Partitioning II Solution Note Hard O(n^2) O(n) dp partition
No.1289 Minimum Falling Path Sum II Solution Note Hard O(n^2) O(1) ---
No.1235 Maximum Profit in Job Scheduling Solution Note Hard O(nlogn) O(n) binary search + dynamic programming
No.1510 Stone Game IV Solution Note Hard O(n) O(n) ---
No.1478 Allocate Mailboxes Solution Note Hard O(n^3) O(n) ---
No.97 Interleaving String Solution Note Hard O(n^2) O(n^2) ---

Divide and Conquer

NO. Title Solution Note Difficulty Time Space Tag
No.932 Beautiful Array Solution Note Medium O(nlogn) O(n) ---
No.241 Different Ways to Add Parentheses Solution Note Medium O(n^3) O(n) memo
No.395 Longest Substring with At Least K Repeating Characters Solution Note Medium O(n^2) O(n) ---
No.1274 Number of Ships in a Rectangle Solution Note Medium O(logn) O(logn) ---

Design

NO. Title Solution Note Difficulty Time Space Tag
No.348 Design Tic-Tac-Toe Solution Note Medium O(n) O(n) ---
No.642 Design Search Autocomplete System Solution Note Hard O(n) O(n) TrieNode
No.355 Design Twitter Solution Note Medium O(n) O(n) ---
No.341 Flatten Nested List Iterator Solution Note Medium O(n) O(n) stack
No.353 Design Snake Game Solution Note Medium O(n) O(n) queue
No.379 Design Phone Directory Solution Note Medium O(n) O(1) ---
No.362 Design Hit Counter Solution Note Medium O(1) O(n) ---
No.1032 Stream of Characters Solution Note Hard O(n) O(n) TrieNode
No.745 Prefix and Suffix Search Solution Note Hard O(n) O(n) TrieNode
No.1206 Design Skiplist Solution Note Hard O(nlog) O(n) skiplist
No.1429 First Unique Number Solution Note Medium O(n) O(n) ---
No.1117 Building H2O Solution Note Medium O(n) O(n) ---
No.307 Range Sum Query - Mutable Solution Note Medium init:O(nlogn)/query:O(logn)/update:O(logn) O(n) FenwickTree/Prefix Sum
No.315 Count of Smaller Numbers After Self Solution Note Hard O(nlogn) O(n) FenwickTree/Prefix Sum
No.895 Maximum Frequency Stack Solution Note Hard O(1) O(n) ---
No.1286 Iterator for Combination Solution Note Medium O(C(n,k)) O(k) ---
No.635 Design Log Storage System Solution Note Medium O(n) O(n) ---
No.1472 Design Browser History Solution Note Medium O(1) O(n) ---
No.1244 Design A Leaderboard Solution Note Medium O(n) O(logn) hash table+set

SQL

NO. Title Solution Note Difficulty Time Space Tag
No.183 Customers Who Never Order Solution Note Easy --- --- join
No.1050 Actors and Directors Who Cooperated At Least Three Times Solution Note Easy --- --- groupby+count
No.595 Big Countries Solution Note Easy --- --- or/union
No.1075 Project Employees I Solution Note Easy --- --- round+avg+groupby
No.1082 Sales Analysis I Solution Note Easy --- --- groupby+sum+having+orderby
No.1068 Product Sales Analysis I Solution Note Easy --- --- INNER JOIN
No.1148 Article Views I Solution Note Easy --- --- distinct+orderby
No.1303 Find the Team Size Solution Note Easy --- --- inner join+count
No.1251 Average Selling Price Solution Note Easy --- --- right join+round+sum
No.1327 List the Products Ordered in a Period Solution Note Easy --- --- join+having+sum
No.184 Department Highest Salary Solution Note Medium --- --- group by
No.176 Second Highest Salary Solution Note Easy --- --- order by+offset
No.175 Combine Two Tables Solution Note Easy --- --- left join
No.177 Nth Highest Salary Solution Note Medium --- --- function+offset
No.1341 Movie Rating Solution Note Medium --- --- union+groupby+orderby+like