Skip to content

JunBinLiang/Leetcode-Complete-Guide

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

LeetCode 题解 + 报告 + 课程 📝

题目会有我给予的相对难度评价 ➕ CF的估测难度对应分数

CF 分目测评估:

📗 800-1100 对应 Easy (E)
📙 1200-1700 对应 Medium (M)
📕 1700 - 2100 对应 Hard (H)

(代码以 C++ 和 Java 进行题解)

🏆Crash Courses:

Premium

# Title Difficulty # Title Difficulty
159 Longest Substring with At Most Two Distinct Characters (M-) 1200
243 Shortest Word Distance (E) 900 244 Shortest Word Distance II (M-) 1400
245 Shortest Word Distance III (M-) 1300 246 Strobogrammatic Number (E) 900
247 Strobogrammatic Number II (M) 1500 248 Strobogrammatic Number III (H-) 1700
250 Count Univalue Subtrees (M-) 1300 252 Meeting Rooms (E) 900
253 Meeting RoomsII (M) 1500 254 Factor Combinations (M-) 1400
256 Paint House (M-) 1400
261 Graph Valid Tree (M-) 1400 265 Paint House II (H-) 1700
266 Palindrome Permutation (E) 900 267 Palindrome Permutation II (M) 1500
269 Alien Dictionary (H-) 1700 270 Closest Binary Search Tree Value (E) 1000
272 Closest Binary Search Tree Value II (H-) 1700
277 Find the Celebrity (M) 1500 286 Walls and Gates (M-) 1400
288 Unique Word Abbreviation (M-) 1400 291 Word Pattern II (H) 1800
293 Flip Game (E) 800
296 Best Meeting Point (H-) 1700 294 Flip Game II(MIN_MAX) (M) 1500
305 Number of Islands II (H-) 1700 317 Shortest Distance from All Buildings (H-) 1700
323 Number of Connected Components in an Undirected Graph (M-) 1500
325 Maximum Size Subarray Sum Equals k (M-) 1300 339 Nested List Weight Sum (E) 1000
340 Longest Substring with At Most K Distinct Characters (H-) 1600 358 Rearrange String k Distance Apart (H-) 1600
359 Logger Rate Limiter (E) 800
360 Sort Transformed Array (E) 1000 366 Find Leaves of Binary Tree (M-) 1400
370 Range Addition (M) 1500 379 Design Phone Directory (M-) 1200
411 Minimum Unique Word Abbreviation (H) 1800 422 Valid Word Square (E) 1000
425 Word Squares (H) 1800 428 Serialize and Deserialize N-ary Tree (H-) 1700
431 Encode N-ary Tree to Binary Tree (H-) 1700 465 Optimal Account Balancing (H) 1800
471 Encode String with Shortest Length (String + Interval DP) (H) 1900 487 Max Consecutive Ones II (M-) 1300
490 The Maze (M) 1500 499 The Maze III (H) 1800
505 The Maze II (M+) 1600 510 Inorder Successor in BST II (M) 1500
527 Word Abbreviation (H) 1800
531 Lonely Pixel I (M-) 1400 544 Output Contest Matches (M) 1500
545 Boundary of Binary Tree (M) 1500 548 Split Array with Equal Sum (M) 1500
562 Longest Line of Consecutive One in Matrix (M-) 1400
568 Maximum Vacation Days (H-) 1700 573 Squirrel Simulation (M) 1500
582 Kill Process (M-) 1400
604 Design Compressed String Iterator (E) 1000
624 Maximum Distance in Arrays (M-) 1400 625 Minimum Factorization (M-) 1400
634 Find the Derangement of An Array (H) 1800 642 Design Search Autocomplete System (H) 1800
644 Maximum Average Subarray II (H) 1800 651 4 Keys Keyboard (M+) 1600
656 Coin Path (H-) 1700 660 Remove 9 (M) 1500
663 Equal Tree Partition (M-) 1400
681 Next Closest Time (M) 1500
683 K Empty Slots (H--) 1500 702 Search in a Sorted Array of Unknown Size (M-) 1200
716 Max Stack (E+) 1200 727 Minimum Window Subsequence (H) 1800
742 Closest Leaf in a Binary Tree (M-) 1400 750 Number Of Corner Rectangles (M) 1500
755 Pour Water (M-) 1400
759 Employee Free Time (H-) 1600 760 Find Anagram Mappings (E) 900
774 Minimize Max Distance to Gas Station (H-) 1700 1004 Max Consecutive Ones III (M-) 1300
1055 Shortest Way to Form String (M-) 1300 1056 Confusing Number (E) 900
1059 All Paths from Source Lead to Destination (M) 1500 1061 Lexicographically Smallest Equivalent String (M) 1500
1063 Number of Valid Subarrays (H-) 1600
1064 Fixed Point (E-) 600 1066 Campus Bikes II (M+) 1600
1067 Digit Count in Range(Math) (H+) 2000
1085 Sum of Digits in the Minimum Number (E) 800 1087 Brace Expansion (M) 1500
1088 Confusing Number II (H-) 1700
1099 Two Sum Less Than K (E) 800
1100 Find K-Length Substrings With No Repeated Characters (M-) 1200 1101 The Earliest Moment When Everyone Become Friends (M) 1500
1102 Path With Maximum Minimum Value (M+) 1600
1119 Remove Vowels from a String (E-) 700 1120 Maximum Average Subtree (M-) 1200
1121 Divide Array Into Increasing Sequences (Greedy) (H-) 1700 1133 Largest Unique Number (E) 800
1134 Armstrong Numbert (E) 800 1135 Connecting Cities With Minimum Cost (M-) 1400
1136 Parallel Courses (H-) 1600 1150 Check If a Number Is Majority Element in a Sorted Array (E) 900
1151 Minimum Swaps to Group All 1's Together (M-) 1200 1167 Minimum Cost to Connect Sticks (M-) 1400
1168 Optimize Water Distribution in a Village (H) 1800 1180 Count Substrings with Only One Distinct Letter (E) 1000
1181 Before and After Puzzle (M-) 1200
1183 Maximum Number of Ones (H) 1800 1196 How Many Apples Can You Put into the Basket (E) 800
1199 Minimum Time to Build Blocks (H-) 1700
1213 Intersection of Three Sorted Arrays (E+) 1100
1216 Valid Palindrome III (区间dp) (H-) 1700 1229 Meeting Scheduler (M-) 1400
1243 Array Transformation (E) 900 1244 Design A Leaderboard (M-) 1200
1246 Palindrome Removal (区间dp) (H) 1800 1251 Stepping Numbers (M-) 1400 (M-) 1400
1257 Smallest Common Region (LCA) (M) 1500 1273 Delete Tree Nodes (M) 1500
1259 Handshakes That Don't Cross (H-) 1700 1426 Counting Elements (E) 900
1427 Perform String Shifts (E) 1000
1429 First Unique Number (M) 1500 1469 Find All The Lonely Nodes (E) 900
1474 Delete N Nodes After M Nodes of a Linked Lists (E) 1000 1485 Clone Binary Tree With Random Pointer (M) 1500
1506 Find Root of N-Ary Tree (M-) 1300 1522 Diameter of N-Ary Tree (M-) 1300
1548 The Most Similar Path in a Graph (H) 1800
1554 Strings Differ by One Character (M-) 1400 1564 Put Boxes Into the Warehouse I (M) 1500
1570 Dot Product of Two Sparse Vectors (M-) 1200 1580 Put Boxes Into the Warehouse II (M+) 1600
1602 Find Nearest Right Node in Binary Tree (M-) 1300 1612 Check If Two Expression Trees are Equivalent (M-) 1300
1618 Maximum Font to Fit a Sentence in a Screen (M-) 1400 1628 Design an Expression Tree With Evaluate Function (M-) 1400
1634 Add Two Polynomials Represented as Linked Lists (M-) 1400 1644 Lowest Common Ancestor of a Binary Tree II (M-) 1400
1650 Lowest Common Ancestor of a Binary Tree III (M-) 1400 1660 Correct a Binary Tree (M-) 1400
1666 Change the Root of a Binary Tree (M) 1500 1676 Lowest Common Ancestor of a Binary Tree IV (M) 1500
1682 Longest Palindromic Subsequence II (M+) 1600 1692 Count Ways to Distribute Candies (H) 1800
1698 Number of Distinct Substrings in a String (H) 1800

Array

#27. Remove Element (E) 800
#41. First Missing Positive (H-) 1600
#54. Spiral Matrix (M-) 1400
#66. Add one (E) 900
#73. Set Matrix Zeroes (M-) 1300
#88. Merge Array (E) 1000
#134. Gas Station (M-) 1400
#189. Rotate Array(M) 1500
#228. Summary Ranges(E) 1000
#268. Missing Number(E) 900
#289. Game of Life (M-) 1400
#349. Intersection of Two Arrays(E) 900
#350. Intersection of Two Arrays II(E) 900
#414. Third Maximum Number (E) 900
#419. Battleships in a Board(M-) 1300
#442. Find All Duplicates in an Array (M-) 1400
#448. Find All Numbers Disappeared in an Array(E) 1000
#495. Teemo Attacking (M-) 1200
#599. Minimum Index Sum of Two Lists (E) 900
#622. Design Circular Queue (M-) 1400
#611. Image Smoother (E) 800
#665. Non-decreasing Array (E+) 1200
#795. Number of Subarrays with Bounded Maximum (M) 1500
#797. All Paths From Source to Target (M) 1500
#849. Maximize Distance to Closest Person (M-) 1400
#852. Peak Index in a Mountain Array (E) 800
#867. Transpose Matrix (E) 900
#900. RLE Iterator (M-) 1300
#905. Sort Array By Parity (E) 800
#941. Valid Mountain Array (E) 900
#944. Delete Columns to Make Sorted (E) 900
#1144. Decrease Elements To Make Array Zigzag (M) 1500
#1331. Rank Transform of an Array (E) 1000
#1352. Product of the Last K Numbers (M-) 1400
#1380. Lucky Numbers in a Matrix (E) 900
#1381. Design a Stack With Increment Operation (M) 1500
#1572. Matrix Diagonal Sum (E) 800
#1582. Special Positions in a Binary Matrix(E) 900
#1588. Sum of All Odd Length Subarrays(E) 800
#1589. Maximum Sum Obtained of Any Permutation (M) 1500
#1646. Get Maximum in Generated Array (E) 800
#1652. Defuse the Bomb (E) 900


BFS

#117. Populating Next Right Pointers in Each Node II (M) 1400
#310. Minimum Height Tree (M+) 1600
#433. Minimum Genetic Mutation (M) 1500
#513. Find Bottom Left Tree Value (M-) 1300
#542. 01 Matrix (M) 1500
#675. Cut Off Trees for Golf Event (H-) 1700
#766. Toeplitz Matrix (M) 1400
#838. Push Dominoes (M) 1500
#847. Shortest Path Visiting All Nodes (H) 1800
#854. K-Similar String (H) 1800
#994. Rotting Orange (M) 1400
#1036. Escape a Large Maze (H) 1800
#1263. Minimum Moves to Move a Box to Their Target Location (H) 1900
#1298. Maximum Candies You Can Get from Boxes (H-) 1700
#1329. Sort the Matrix Diagonally (M) 1500
#1439. Find the Kth Smallest Sum of a Matrix With Sorted Rows (H) 1800
#1625. Lexicographically Smallest String After Applying Operations (M) 1500
#1631. Path With Minimum Effort (M) 1500
#1654. Minimum Jumps to Reach Home(M+) 1600
#LCP 09. 最小跳跃次数 (H) 1800


DFS

#17. Letter Combinations of a Phone Number (M-) 1400
#39. Combination Sum (M-) 1400
#40. Combination Sum II (M-) 1400
#130. Surrounded Regions (M-) 1400
#131. Palindrome Partitioning (M) 1500
#216. Combination Sum III (M-) 1400
#301. Remove Invalid Parentheses (H-) 1600
#306. Additive Number (M) 1500
#386. Lexicographical Numbers (M) 1500
#417. Pacific Atlantic Water Flow (M+) 1600
#473. Matchsticks to Square (M+) 1600
#488. Zuma Game (H) 1800
#491. Increasing Subsequences (M) 1500
#547. Friend Circles (M-) 1400
#565. Array Nesting (M-) 1400
#690. Employee Importance (M-) 1200
#761. Special Binary String (H) 1800
#841. Keys and Rooms (M) 1500
#842. Split Array into Fibonacci Sequence(M+) 1600
#967. Numbers With Same Consecutive Differences (M) 1500
#979. Distribute Coins in Binary Tree (M+) 1600
#988. Smallest String Starting From Leaf (M) 1500
#1020. Number of Enclaves (M-) 1400
#1239. Maximum Length of a Concatenated String with Unique Characters (M) 1500
#1240. Tiling a Rectangle with the Fewest Squares (H+) 2000
#1255. Maximum Score Words Formed by Letters (H-) 1700
#1377. Frog Position After T Seconds (M+) 1600
#1559. Detect Cycles in 2D Grid (H-) 1700
#1601. Maximum Number of Achievable Transfer Requests (H-) 1700
#LCP7. 传递信息 (M) 1400


Stack

#56. Merge Intervals (M-) 1400
#57. Insert Interval(M-) 1400
#84. Largest Rectangle in Histogram (H-) 1700
#94. Binary Tree Inorder Traversal (M-) 1400
#150. Evaluate Reverse Polish Notation (M) 1500
#316. Remove Duplicate Letters (M+) 1600
#402. Remove K Digits (M) 1500
#682. Baseball Game (E+) 1100
#735. Asteroid Collision (M-) 1400
#844. Backspace String Compare (E) 900
#1003. Check If Word Is Valid After Substitutions (M-) 1400
#1047. Remove All Adjacent Duplicates In String (E) 1000
#1063. Number of Valid Subarrays (H-) 1700
#1081. Smallest Subsequence of Distinct Characters (M+) 1600
#1190. Reverse Substrings Between Each Pair of Parentheses (M-) 1400
#1209. Remove All Adjacent Duplicates in String II (M-) 1400
#1249. Minimum Remove to Make Valid Parentheses (M-) 1400
#1544. Make The String Great (E+) 1100
#1597. Build Binary Expression Tree From Infix Expression (H-) 1700
#1614. Maximum Nesting Depth of the Parentheses (E) 900
#1673. Find the Most Competitive Subsequence (M-) 1400


LinkedList

Note: LinkedList can be used as stack or queue or deque

#2. Add Two Numbers (M-) 1300
#19. Remove Nth Node From End of List (M-) 1400
#24. Swap Nodes in Pairs (M) 1500
#25. Reverse Nodes in k-Group (H-) 1700
#82. Remove Duplicates from Sorted List II (M-) 1300
#83. Remove Duplicates from Sorted List (E) 1000
#86. Partition List (M-) 1300
#92. Reverse LinkedList II (M) 1500
#141. Linked List Cycle (E) 1000
#143. Reorder List (M-) 1400
#147. Insertion Sort List (M-) 1200
#203. Remove Linked List Elements (E) 900
#237. Delete Node in a Linked List(E) 1000
#328. Odd Even Linked List (M-) 1300
#341. Flatten Nested List Iterator (M-) 1400
#430. Flatten a Multilevel Doubly Linked List (M) 1500
#707. Design Linked List (M-) 1400
#817. Linked List Components (M-) 1300
#876. Middle of the Linked List (E) 900
#950. Reveal Cards In Increasing Order (M) 1500
#1669. Merge In Between Linked Lists (E) 1000


Greedy

#45. Jump Game II (H-) 1600
#135. Candy (H-) 1700
#218. Skyline Problem (H) 1800
#253. Meeting Room II (M) 1500
#406. Queue Reconstruction by Height (M) 1500
#435. Non-overlapping Intervals (M) 1500
#452. Minimum Number of Arrows to Burst Balloonss (M) 1500
#522. Longest Uncommon Subsequence II (M-) 1300
#556. Next Greater Element III (M) 1500
#605. Can Place Flowers(E+) 1100
#630. Course Schedule III (H-) 1700
#659. Split Array into Consecutive Subsequences (M) 1500
#699. Falling Squares (H-) 1700
#738. Monotone Increasing Digits (M) 1500
#763. Partition Labels (M) 1500
#765. Couple Holding Hands (H-) 1600
#767. Reorganize String (M) 1500
#857. Minimum Cost to Hire K Workers (H) 1800
#861. Score After Flipping Matrix (M) 1500
#870. Advantage Shuffle (M) 1500 (sort+2 pointer)
#910. Smallest Range II (H-) 1700
#1007. Minimum Domino Rotations For Equal Row (M) 1500
#1029. Two City Scheduling (M+) 1600
#1090. Largest Values From Labels (M-) 1300
#1111. Maximum Nesting Depth of Two Valid Parentheses Strings (M+) 1600
#1121. Divide Array Into Increasing Sequence (H-) 1700
#1199. Minimum Time Building Block (H) 1800
#1288. Remove Covered Intervals (M-) 1400
#1296. Divide Array in Sets of K Consecutive Numbers (M-) 1400
#1326.Minimum Number of Taps to Open to Water a Garden (H) 1800
#1328.Break a Palindrome (M-) 1300
#1338.Reduce Array Size to The Half (M-) 1300
#1383.Maximum Performance of a Team (H-) 1700
#1400.Construct K Palindrome Strings (M) 1500
#1414.Find the Minimum Number of Fibonacci Numbers Whose Sum Is K (M+) 1600
#1432.Max Difference You Can Get From Changing an Integer (M-) 1400
#1433.Check If a String Can Break Another String (M-) 1400
#1520.Maximum Number of Non-Overlapping Substrings (H) 1900
#1540.Can Convert String in K Moves (M) 1500
#1591.Strange Printer II (H) 1800
#1605.Find Valid Matrix Given Row and Column Sums (M+) 1700
#1632.Rank Transform of a Matrix (H+) 2000
#1642.Furthest Building You Can Reach (M+) 1600
#1663.Smallest String With A Given Numeric Value (M-) 1400
#1665. Minimum Initial Energy to Finish Tasks (H-) 1700
#1702. Maximum Binary String After Change (M) 1500
#LCP 06. 拿硬币 (E) 800


Graph

#126. Word Ladder II(H) 1900
#133. Clone Graph(M) 1500
#785. Is Graph Bipartite?(M) 1500
#802. Find Eventual Safe States(M+) 1700
#863. All Nodes Distance K in Binary Tree(M) 1500
#886. Possible Bipartition(M) 1500
#1042. Flower Planting With No Adjacent(E+) 1300
#1153. String Transform into another String (H-) 1700
#1192. Critical Connection (H) 1900
#1245. Tree Diameter (M-) 1400
#1334. Find the City With the Smallest Number of Neighbors at a Threshold Distance (M) 1500 (Floyd-Warshall)
#1361. Validate Binary Tree Nodes (M) 1500
#1522. Diameter of N-Ary Tree (M-) 1300
#1568. Minimum Number of Days to Disconnect Island (H-) 1700
#1615. Maximal Network Rank (M) 1500


Maxflow - Bipartite Matching (二分图匹配)

  1. The size of a maximum flow in the resulting graph equals the size of a maximum matching in the original graph.
  2. Size of a minimum node cover always equals the size of a maximum matching.
  3. The complement of a maximum independent set is a minimum vertex cover(MAX Flow).
    Reference : https://ali-ibrahim137.github.io/competitive/programming/2020/01/02/maximum-independent-set-in-bipartite-graphs.html
    最大流: https://blog.csdn.net/chinacoy/article/details/45040897

#1349. Maximum Students Taking Exam (H+) 2000
#LCP04. 覆盖 (H+) 2000


Binary Search

#34. Find First and Last Position of Element in Sorted Array (M-) 1300
#35. Search Insert Position (E) 1000
#69. Sqrt(x) (E+) 1100
#153. Find Minimum in Rotated Sorted Array (M+) 1600
#154. Find Minimum in Rotated Sorted Array II (H-) 1700
#275. H Index II (M-) 1400
#302. 包含全部黑色像素的最小矩形 (H-) 1700
#352. Data Stream as Disjoint Intervals (H-) 1700
#373. Find K Pairs with Smallest Sums (M) 1500
#374. Guess Number Higher or Lower (E) 800
#436. Find Right Interval (M) 1500
#475. Heaters (M) 1500
#483. Smallest Good Base (H) 1800
#540. Single Element in a Sorted Array (M-) 1400
#704. Binary Search(E) 900
#744. Find Smallest Letter Greater Than Target (M-) 1200
#786. K-th Smallest Prime Fraction (H) 1800
#792. Number of Matching Subsequences (M+) 1600
#911. Online Election(M) 1500
#1095. Find in Mountain Array (H-) 1700
#1146. Snapshot Array (M-) 1400
#1292. Maximum Side Length of a Square with Sum Less than or Equal to Threshold (M+) 1600
#1533. Find the Index of the Large Integer (M) 1500
#1552. Magnetic Force Between Two Balls (M+) 1600
#1574. Shortest Subarray to be Removed to Make Array Sorted (M+) 1600
#LCP08. 剧情触发时间 (M) 1600
#LCP12. 小张刷题计划 (M) 1500


Tree

#95. Unique Binary Search Trees II(M+) 1600
#96. Unique Binary Search Trees (M+) 1600
#98. Validate Binary Search Tree (M) 1500
#101. Symmetric Tree (M-) 1300
#110. Balanced Binary Tree (E) 900
#173. Binary Search Tree Iterator (M) 1500
#222. Count Complete Tree Nodes (M) 1500
#235. Lowest Common Ancestor of a Binary Search Tree (E+) 1100
#236. Lowest Common Ancestor of a Binary Tree (M-) 1400
#257. Binary Tree Paths (E) 1000
#297. Serialize and Deserialize Binary Tree (H-) 1700
#404. Sum of Left Leaves (E) 900
#437. Path Sum III(M-) 1400
#606. Construct String from Binary Tree (E+) 1100
#617. Merge Binary Tree (E) 1000
#623. Add One Row to Tree (M-) 1300
#654. Maximum Binary Tree (M-) 1400
#669. Trim a Binary Search Tree (M-) 1400
#687. Longest Univalue Path(M) 1500
#783. Minimum Distance Between BST Nodes (E) 900
#814. Binary Tree Pruning (M-) 1200
#872. Leaf-Similar Trees (E) 900
#971. Flip Binary Tree To Match Preorder Traversal (M) 1500
#993. Cousins in Binary Tree (E) 900
#1026. Maximum Difference Between Node and Ancestor (M-) 1400
#1028. Recover a Tree From Preorder Traversal (H-) 1700
#1038. Binary Search Tree to Greater Sum Tree (M-) 1400
#1080. Insufficient Nodes in Root to Leaf Paths (M) 1500
#1110. Delete Nodes And Return Forest (M-) 1400
#1123. Lowest Common Ancestor of Deepest Leaves (M) 1500
#1339. Maximum Product of Splitted Binary Tree (M) 1500
#1372. Longest ZigZag Path in a Binary Tree (M) 1500
#1457. Pseudo-Palindromic Paths in a Binary Tree (M-) 1300
#1490. Clone N-tree (M-) 1300
#1516. Move Sub-Tree of N-Ary Tree (H-) 1700
#1617. Count Subtrees With Max Distance Between Cities (H) 1800
#1719. Number Of Ways To Reconstruct A Tree (H+) 2100


Trie

#208. Implement Trie (Prefix Tree) (M) 1500
#211. Design Add and Search Words Data Structure (M) 1500
#421. Maximum XOR of Two Numbers in an Array (M+) 1600
#588. Design In-Memory File System (H) 1800
#1707. Maximum XOR With an Element From Array (H) 1800


DP

#10. Regular Expression Matching (H) 1900
#44. Wildcard Matching (H-) 1700
#70. Climbing Stairs (E) 900
#85. Maximal Rectangle (H-) 1700
#91. Decode Way (M+) 1700
#97. Interleaving String (H-) 1700
#118. Pascal's Triangle (E) 900
#119. Pascal's Triangle II (E) 1000
#120. Triangle (M-) 1300
#123. Best Time to Buy and Sell Stock III (H-) 1700
#132. Palindrome Partitioning II (H-) 1700
#139. Word Break (M) 1500
#140. Word Break II (H) 1800
#188. Best Time to Buy and Sell Stock IV (H) 1800
#198. House Robber (M) 1400
#213. House Robber II (M) 1500
#279. Perfect Square(M-) 1300
#309. Best Time to Buy and Sell Stock with Cooldown (M) 1500
#312. Burst Balloons (H) 1800
#322. Coin Change (M-) 1400
#363. Max Sum of Rectangle No Larger Than K (M) 1800
#403. Frog Jump (H-) 1700
#413. Arithmetic Slices (M) 1500
#446. Arithmetic Slices II - Subsequence (H-) 1700
#449. Serialize and Deserialize BST (M) 1500
#466. Count Repetition (H) 1800
#494. Target Sum (M) 1500
#514. Freedom Trail (H) 1800
#518. Coin Change 2 (M) 1500
#583. Delete Operation for Two Strings (M) 1500
#673. Number of Longest Increasing Subsequence (M) 1500
#691. Stickers to Spell Word (H) 1900
#714. Best Time to Buy and Sell Stock with Transaction Fee (M+) 1600
#717. 1-bit and 2-bit Characters (E) 1000
#718. Maximum Length of Repeated Subarray (M) 1500
#727. Minimum Window Subsequence (H) 1800
#730. Count Different Palindromic Subsequences (H) 1800
#740. Delete and Earn (M) 1500
#741. Cherry Pickup (H) 1800
#764. Largest Plus Sign (M) 1500
#790. Domino and Tromino Tiling(M+) 1700
#798. Smallest Rotation with Highest Score (H) 1900
#801. Minimum Swaps To Make Sequences Increasing (M+) 1600
#805. Split Array With Same Average (H) 1800
#823. Binary Trees With Factors (M) 1500
#828. Count Unique Characters of All Substrings of a Given String (H) 1900
#837. New 21 Game (M+) 1600
#887. Supper Egg drop (H) 1800
#902. Numbers At Most N Given Digit Set (H) 1800
#903. Valid Permutations for DI Sequence (H) 1800
#918. Maximum Sum Circular Subarray (M) 1500
#920. Number of Music Playlists (H) 1800
#926. Flip String to Monotone Increasing(M-) 1400
#940. Distinct Subsequences II (H) 1800
#943. Find the Shortest Superstring (H) 1900
#964. Least Operators to Express Number (H) 1900
#968. Binary Tree Camera (H+) 2000
#975. Odd Even Jump (H-) 1700
#978. Longest Turbulent Subarray (M) 1500
#983. Minimum Cost For Tickets (M) 1500
#1000. Minimum Cost to Merge Stones (H+) 2000
#1012. Numbers With Repeated Digits (H) 1800
#1027. Longest Arithmetic Subsequence (M) 1500
#1029. Two City Scheduling (M) 1500
#1039. Minimum Score Triangulation of Polygon (M+) 1700
#1066. Campus Bike II (H-) 1700
#1092. Shortest Common Supersequenceg (H) 1800
#1130. Minimum Cost Tree From Leaf Values (M) 1500
#1137. N-th Tribonacci Number (E) 900
#1139. Largest 1-Bordered Square (M) 1600
#1155. Number of Dice Rolls With Target Sum (M+) 1600
#1187. Make Array Strictly Increasing (H) 1800
#1125. Smallest Sufficient Team (H) 1800
#1227. Airplane Seat Assignment Probability (M+) 1600
#1259. Handshakes That Don't Cross (H-) 1700
#1277. Count Square Submatrices with All Ones (M) 1500
#1359. Count All Valid Pickup and Delivery Options (H-) 1700
#1388. Pizza With 3n Slices (H) 1800
#1402. Reducing Dishes (H-) 1600
#1420. Build Array Where You Can Find The Maximum Exactly K Comparisons(H) 1800
#1458. Max Dot Product of Two Subsequences (H-) 1600
#1473. Paint House III (H) 1800
#1478. Allocate Mailboxes (H) 1900
#1546. Maximum Number of Non-Overlapping Subarrays With Sum Equals Target (M+) 1600
#1548. The Most Similar Path in a Graph (H) 1800
#1563. Stone Game V (H-) 1700
#1563. Number of Ways to Reorder Array to Get Same BST (H) 1900
#1575. Count All Possible Routes (H) 1800
#1621. Number of Sets of K Non-Overlapping Line Segments (M+) 1700
#1639. Number of Ways to Form a Target String Given a Dictionary (H) 1800
#1641. Count Sorted Vowel Strings (M-) 1400
#1653. Minimum Deletions to Make String Balanced (M) 1500
#1655. Distribute Repeating Integers(H) 1800
#1659. Maximize Grid Happiness(H+) 2200
#1671. Minimum Number of Removals to Make Mountain Array(H-) 1600
#1681. Minimum Incompatibility (H) 1800
#1687. Delivering Boxes from Storage to Ports (H+) 2000
#1691. Maximum Height by Stacking Cuboids (H) 1800
#1696. Jump Game VI (M+) 1600
#1723. Find Minimum Time to Finish All Jobs (H) 1800
#LCP10. 二叉树任务调度 (H+) 2200
#LCP13. 寻宝 (H+) 2100
#LCP14. 切分数组 (H+) 2200


Math

#60. Permutation Sequence (M+) 1600
#172. Factorial Trailing Zeroes (M-) 1400
#233. Number of Digit One (H) 1900
#396. Rotate Function (M-) 1400
#440. K-th Smallest in Lexicographical Order (H+) 1900
#453. Minimum Moves to Equal Array Elements (E+) 1100
#463. Island Perimeter (E) 900
#492. Construct the Rectangle (E) 900
#504. Base 7 (E) 800
#553. Optimal division (M-) 1300
#598. Range Addition II (E) 900
#660. Remove 9 (M) 1500
#799. Champagne Tower(M) 1500
#836. Rectangle Overlap (E+) 1100
#869. Reordered Power of 2 (M-) 1300
#880. Decoded String at Index (M+) 1600
#891. Sum of Subsequence Widths (H) 1800
#888. Fair Candy Swap (E) 1000
#908. Smallest Range I (E+) 1100
#957. Prison Cells After N Days (M) 1500
#976. Largest Perimeter Triangle (E) 900
#1006. Clumsy Factorial (M) 1500
#1018. Binary Prefix Divisible By 5 (E) 1000
#1024. Vedio Stichting (M) 1600
#1041. Robot Bounded In Circle (M) 1500
#1103. Distribute Candies to People(E+) 1300
#1128. Number of Equivalent Domino Pairs (E) 1000
#1131. Maximum of Absolute Value Expression (M+) 1600
#1237. Find Positive Integer Solution for a Given Equation (E) 1000
#1266. Minimum Time Visiting All Points (E) 1000
#1415. The k-th Lexicographical String of All Happy Strings of Length n (M+) 1600
#1465. Maximum Area of a Piece of Cake After Horizontal and Vertical Cuts (M-) 1200
#1498. Number of Subsequences That Satisfy the Given Sum Condition (M+) 1600
#1551. Minimum Operations to Make Array Equal (M-) 1200
#1573. Number of Ways to Split a String (M) 1500
#1622. Fancy Sequence (H+) 2000
#1643. Kth Smallest Instructions (H) 1800
#1648. Sell Diminishing-Valued Colored Balls (M+) 1600
#LCP3. 机器人大冒险 (M) 1500
#LCP11. 期望个数统计 (M-) 1400

Prefix Sum

#1664. Ways to Make a Fair Array (M) 1500

Geometry

#963. Minimum Area Rectangle II (M+) 1700
#1401. Circle and Rectangle Overlapping(M+) 1600
#1453. Maximum Number of Darts Inside of a Circular Dartboard(H+) 2100
#1610. Maximum Number of Visible Points(H) 1800


Moore's Voting

#169. Majority Element (M-) 1200
#229. Majority Element (M) 1500


Segment Tree

#308. Range Sum Query 2D - Mutable (2D Segment Tree) (H) 2100
#715. Range Module (H) 1900
#1505. Minimum Possible Integer After at Most K Adjacent Swaps On Digits (BIT) (H) 1900
#1585. Check If String Is Transformable With Substring Sort Operations (Segment Tree) (H+) 2400
#1649. Create Sorted Array through Instructions (BIT) (H) 1800
#LCP5. 发leetcoin (H+) 2300
#b857. Delete Integers In Ascending Order (BIT) (H) 1800


Sparse Table

#1310. XOR Queries of a Subarray (M) 1500
#1483. Kth Ancestor of a Tree Node (H) 1800


Observation

#667. Beautiful Arrangement II (M) 1500
#777. Swap Adjacent in LR String (M+) 1600
#899. Orderly Queue (H-) 1700
#1109. Corporate Flight Bookings (M) 1500
#1538. Guess the Majority in a Hidden Array (M+) 1700


Sliding Window

#3. Longest Substring Without Repeating Characters (M-) 1400
#76. Minimum Window Substring (M+) 1700
#346. Moving Average from Data Stream (E) 900
#395. Longest Substring with At Least K Repeating Characters (M+) 1700
#424. Longest Repeating Character Replacement (M) 1500
#713. Subarray Product Less Than K (M) 1500
#904. Fruit Into Baskets (M-) 1300
#933. Number of recent call (E) 1000
#992. Subarrays with K Different Integers (H) 1800
#1040. Moving Stones Until Consecutive II (M+) 1600
#1052. Grumpy Bookstore Owner (M) 1500
#1156. Swap For Longest Repeated Character Substring (M) 1500
#1208. Get Equal Substrings Within Budget (M-) 1400
#1456. Maximum Number of Vowels in a Substring of Given Length (M-) 1300
#1675. Minimize Deviation in Array (H) 1800
#1695. Maximum Erasure Value (M-) 1400
#1703. Minimum Adjacent Swaps for K Consecutive Ones (H) 1800


Two Pointer

#80. Remove Duplicates from Sorted Array II (M-) 1400
#455. Assign Cookies (E) 1000
#524. Longest Word in Dictionary through Deleting (M-) 1400
#632. Smallest Range Covering Elements from K Lists (H) 1800
#821. Shortest Distance to a Character (E) 900
#881. Boats to Save People (M-) 1400
#923. 3Sum With Multiplicity (M+) 1600
#925. Long Pressed Name (E) 1000
#986. Interval List Intersections (M) 1500


Sort

#179. Largest Number (M) 1500
#215. Kth Largest Element in an Array (Quick Select) (M) 1500
#252. Meeting Room (E) 1000
#295. Find Median from Data Stream (H-) 1600
#581. Shortest Unsorted Continuous Subarray (E) 1000
#703. Kth Largest Element in a Stream (E) 1000
#791. Custom Sort String (M-) 1300
#912. Sort an Array (M-) 1300
#955. Delete Columns to Make Sorted II (M+) 1600
#1030. Matrix Cells in Distance Order (E) 900
#1366. Rank Teams by Votes (M+) 1600
#1629. Slowest Key (E) 900
#1636. Sort Array by Increasing Frequency (E+) 1100


String

#6. ZigZag Conversion (M-) 1300
#9. Palindrom Number (E) 900
#28. Implement strStr(M) 1500 (KMP)
#49. Group Anagrams (M-) 1300
#151. Reverse Words in a String (M-) 1300
#214. Shortest Palindromem (H-) (KMP) 1700
#242. Valid Anagram (E) 900
#290. Word Pattern (E) 1000
#336. Palindrome Pairs (H) 1800
#481. Magical String (M) 1500
#696. Count Binary Substrings (E) 1000
#833. Find And Replace in String (M) 1500
#811. Subdomain Visit Count (E) 800
#824. Goat Latin (E) 900
#859. Buddy Strings (E) 1000
#906. Super Palindrom (H) 1800
#936. Stamping The Sequence (H+) 2300
#953. Verifying an Alien Dictionary (E) 1000
#1106. Parsing A Boolean Expression (H-) 1700
#1163. Last Substring in Lexicographical Order (H-) 1700
#1309. Decrypt String from Alphabet to Integer Mapping (E) 1000
#1370. Increasing Decreasing String (E) 900
#1446. Consecutive Characters (E) 900
#1616. Split Two Strings to Make Palindrome (M+) 1600
#1624. Largest Substring Between Two Equal Characters (E) 900
#1678. Goal Parser Interpretation (E) 900
#1694. Reformat Phone Number (E) 900
#1704. Determine if String Halves Are Alike (E) 800


Game Theory

#292. Nime Game (M-) 1400
#365. Water and Jug Problem (M+) 1600
#375. Guess Number Higher or Lower II (M+) 1600
#486. Predict the Winner (M) 1500
#521. Longest Uncommon Subsequence I (E) 800
#789. Escape The Ghosts (M-) 1400
#843. Guess The World (H-) 1700
#877. Stone Game (M+) 1600
#913. Cat and Mouse (H+) 2400
#1025. Divisor Game (E+) 1100
#1140. Stone Game II (M+) 1600
#1686. Stone Game VI (M+) 1700
#1690. Stone Game VII (M+) 1600


Implementation

#7. Reverse Integer (E) 900
#26. Remove Duplicates from Sorted Array (E) 800
#68. Text Justification (H) 1800
#202. Happy Number (E) 800
#258. Add Digits (E) 800
#747. Largest Number At Least Twice of Others (E) 900
#806. Number of Lines To Write String (E) 900
#1071. Greatest Common Divisor of Strings (E) 900
#1170. Compare Strings by Frequency of the Smallest Character (E) 900
#1550. Three Consecutive Odds (E-) 700
#1640. Check Array Formation Through Concatenation (E) 1000
#1662. Check If Two String Arrays are Equivalent (E) 800
#1706. Where Will the Ball Fall (M+) 1600


Bit

#201. Bitwise AND of Numbers Range (M+) 1600
#318. Maximum Product of Word Lengths (M) 1500
#784. Letter Case Permutation (M) 1500
#898. Bitwise ORs of Subarrays (M+) 1600
#1178. Number of Valid Words for Each Puzzle (H-) 1700
#1238. Circular Permutation in Binary Representation (M) 1500
#1290. Convert Binary Number in a Linked List to Integer (E) 900
#1371. Find the Longest Substring Containing Vowels in Even Counts (M) 1500
#1318. Minimum Flips to Make a OR b Equal to c (M) 1500
#1404. Number of Steps to Reduce a Number in Binary Representation to One (M+) 1600
#1611. Minimum One Bit Operations to Make Integers Zero (H) 1800


Hash

#30. Substring with Concatenation of All Words(H-) 1700
#219. Contains Duplicate II (E) 800
#220. Contains Duplicate III (M) 1500
#409. Longest Palindrom (E) 900
#594. Longest Harmonious Subsequence (E) 1000
#804. Unique Morse Code Words (E) 800
#825. Friends Of Appropriate Ages(M-) 1300
#884. Uncommon Words from Two Sentences(E) 900
#893. Groups of Special-Equivalent Strings (E) 1000
#939. Minimum Area Rectangle(M) 1500
#954. Array of Doubled Pairs(M-) 1400
#1001. Grid Illumination(H-) 1700
#1267. Count Servers that Communicate (M-) 1300
#1282. Group the People Given the Group Size They Belong To (M-) 1300
#1396. Design Underground System (M) 1500


Divide Conquer

#315. Count of Smaller Numbers After Self(H-) 1700
#327. Count of Range Sum(H) 1800
#454. 4 sum II (M-) 1400
#932. Beautiful Array (M+) 1700


Union Find

#947. Most Stones Removed with Same Row or Column (M) 1500
#990. Satisfiability of Equality Equations (M) 1500
#1202. Smallest String With Swaps (M+) 1600
#1579. Remove Max Number of Edges to Keep Graph Fully Traversable (H) 1900
#1584. Min Cost to Connect All Points (M) 1500
#1627. Graph Connectivity With Threshold (H) 1800
#1697. Checking Existence of Edge Length Limited Paths (H) 1800
#1722. Minimize Hamming Distance After Swap Operations (M) 1500


Ordered Map

#1606. Find Servers That Handled Most Number of Requests(H) 1800


Line Sweep

#391. Perfect Rectangle(H) 1800
#729. My Calendar I (M) 1500
#731. My Calendar II (M+) 1600
#1674. Minimum Moves to Make Array Complementary(H-) 1700


Data Structure

#146. LRU Cache (M+) 1600
#460. LFU (H) 1800
#860. Rectangle Area II (H) 1800
#895. Maximum Frequency Stack (H-) 1700
#1172. Dinner Plate Stacks (H) 1800


SQL

#175. Combine Two Tables (E)
#177. Nth Highest Salary (M)
#180. Consecutive Numbers (M)
#181. Employees Earning More Than Their Managers (E)
#182. Duplicate Emails (E)
#183. Customers Who Never Order (E)
#184. Department Highest Salary (M)
#197. Rising Temperature (E)
#511. Game Play Analysis I (E)
#595. Big Countries (E)
#596. Classes More Than 5 Students (E)
#607. Sales Person (E)
#620. Not Boring Movie (E)
#1082. Sales Analysis I (E)
#1303. Find the Team Size (E)
#1407. Top Travellers (E)
#1565. Unique Orders and Customers Per Month (E)



力扣秋季赛

#LCP17. 速算机器人 (E) 900
#LCP18. 早餐组合 (M-) 1400
#LCP19. 秋叶收藏集 (M+) 1600
#LCP20. 快速公交 (H) 1800
#LCP21. 追逐游戏 (H) 1900

力扣2020秋季战队赛

#LCP22. 黑白方格画 (M) 1500
#LCP23. 魔术排列 (M+) 1600
#LCP24. 数字游戏 (H+) 2000
#LCP25. 古董键盘 (H) 1900
#LCP26. 导航装置 (H+) 2400
#LCP27. 黑盒光线反射 (H+) 2300




📌 ACM 练习

精刷 200 题
参照以下 links:
🔗 https://github.com/yogykwan/acm-challenge-workbook
🔗 https://blog.csdn.net/u011613729/article/details/9788669


Two pointer

#POJ 2739. Sum of Consecutive Prime Numbers (M) 1500


DFS

#POJ 1979. Red and Black (M-) 1400


枚举

#POJ 1753. Flip Game (H) 1800


反转(开关)

#POJ 3185. The Water Bowls (M+) 1600


Minimum Spanning Tree

#POJ 1258. Agri-Net POJ (M) 1600


Strong Connect Component (强连通)

🔗 Source: https://iq.opengenus.org/tarjans-algorithm/ (Tarjan for SCC)
Tarjan 和Kosaraju’s 同等适用与找强连通
#POJ 1236. Network of Schools (H+) 2200
#POJ 3713. Transferring Sylla (H+) 2200


Binary Search

#POJ 3685. Matrix (H) 1800


DP

#POJ 1159. Palindrom (H-) 1700
#POJ 1458. Balance (M) 1500
#POJ 1837. Balance (H-) 1700
#POJ 2229. Sumsets (M) 1500
#POJ 2479. Maximum sum (M+) 1600


贪心

#POJ 1844. Sum (M+) 1600
#POJ 3614. Sunscreen (H-) 1700


二分图匹配

#POJ 1274. The Perfect Stall (H-) 1700







Algorithm Template

Suffix Array (后缀数组 (nlog^2 n))
Suffix Array + LCP
Combination C(n,k) in mod
Max Flow Dinic
Shortest Path
2 SAT
Kosaraju
Fenwick Tree
Hopcroft (Solving Maximum matching Cardinality for Bipartile Graph) O(sqrt(n)*m)
Min Seg
Segment Tree Set Range
Segment Tree Update Range
Range Update Min Lazy Seg
Lazy Seg
2D Seg
Double Linkedlist
Infix to Postfix Expression
Manacher
Convex Hull Trick
UF
Matrix Exp
Catalan Number
First 5000 prime Number
Bellmen Ford (LC 743)
Discrete Line Sweep
莫队
可修莫队 CF940F
mcmf
?th permutation of String
z- Algorithm
Interval Insert
Merge_Set
Inverse Pair
GCD
Euler
Weight-1 Shortest Cycle
xor a big range
fft
Mobius
PersistentSeg
Euler Path/Circuit
Rolling Hash
Sparse Table Range Query
Java Templates

参考

  1. 最大权闭合子图 (https://www.cnblogs.com/TreeDream/p/5942354.html#_labelTop) (强顶)
    证明 1: https://blog.csdn.net/yo_bc/article/details/75322370
    证明 2: https://www.cnblogs.com/dilthey/p/7565206.html
  2. 2-SAT Template:
    https://github.com/JunBinLiang/Competitive-Coding/blob/master/2-SAT.cpp
    https://cp-algorithms.com/graph/2SAT.html#toc-tgt-2

Selected Topic :

  1. Chinese Remainder Theory
  2. Catalan Number
  3. 约分
  4. 倍增LCA
  5. 次小生成树
  6. 约数之和
  7. Dynamic Connectivity (UF with Delete) (Segment Tree need)
  8. 最小割入门, 参考LCP38
  9. 莫队,可修莫队
  10. Minumum Cost Max Flow (最小费用最大流)
  11. Boruvka’s algorithm (MST)O(m logn)
  12. Nim Game
  13. 莫比乌斯数
  14. 图的三/四元 环
  15. Centroid Decomposition
  16. 组合数学

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Contributors 3

  •  
  •  
  •