NeetCode Comprehensive Algorithm Bank & Offline Handbook
Synchronized bilingual toggle with dual NeetCode & LeetCode problem numbering and direct links. Features step-by-step logic, benchmark Python3 code, complexity analysis, interview pitfalls, and standalone offline exports.
Coin Change II (零钱兑换 II)
Given an integer array coins and an integer amount, return the number of combinations that make up amount using an unlimited suppl...
Target Sum (目标和)
Given an integer array nums and an integer target, assign a + or - sign to every element so that the resulting expression equals t...
Interleaving String (交错字符串)
Given strings s1, s2, and s3, return true if s3 is formed by interleaving s1 and s2 while preserving the relative order of the cha...
Stone Game (石子游戏)
There is a row of piles with an even number of piles. Alice and Bob alternately take a whole pile from either end, each maximising...
Stone Game II (石子游戏 II)
Alice and Bob take turns taking piles from the front of piles. On a turn a player takes X piles with 1 <= X <= 2M, then M be...
Longest Increasing Path in a Matrix (矩阵中的最长递增路径)
Given an m x n integer matrix, return the length of the longest strictly increasing path, moving up, down, left, or right (no diag...
Maximal Square (最大正方形)
Given an m x n binary matrix of 0 and 1, find the area of the largest square containing only 1s. Constraints: 1 <= m, n <= 3...
Count Square Submatrices with All Ones (统计全为 1 的正方形子矩阵)
Given an m x n binary matrix of 0 and 1, return the number of square submatrices that contain only 1s. Constraints: 1 <= m, n &...
Ones and Zeroes (一和零)
Given an array of binary strings strs and integers m and n, find the largest subset that contains at most m zeros and at most n on...
2 Keys Keyboard (只有两个键的键盘)
A notepad starts with one A. Two operations are available: Copy All copies everything currently on screen, and Paste appends the c...
Maximum Alternating Subsequence Sum (最大交替子序列和)
Given an array nums, the alternating sum of a subsequence is the sum of its elements at even indices minus the sum of those at odd...
Distinct Subsequences (不同的子序列)
Given strings s and t, return the number of distinct subsequences of s that equal t. The answer fits in a signed 32-bit integer. C...
Edit Distance (编辑距离)
Given strings word1 and word2, return the minimum number of insertions, deletions, or replacements needed to convert word1 into wo...
Number of Dice Rolls With Target Sum (掷骰子等于目标和的方法数)
You roll n dice, each with k faces numbered 1 to k. Return the number of ways the face-up numbers can sum to target, modulo 1e9+7....
Minimum Falling Path Sum (下降路径最小和)
Given an n x n matrix, a falling path starts at any cell of the first row and moves to the next row choosing a column that differs...
Out of Boundary Paths (出界的路径数)
A ball sits at (startRow, startColumn) of an m x n grid. In one move it moves to one of the four adjacent cells. Return the number...
Longest Ideal Subsequence (最长理想子序列)
Given a lowercase string s and an integer k, a subsequence is ideal if the alphabet distance between every two consecutive chosen ...
Count Number of Teams (统计作战单位数)
There are n soldiers with ratings rating[i]. A team of three indices i < j < k is valid if their ratings are strictly increa...
Shortest Common Supersequence (最短公共超序列)
Given two strings str1 and str2, return the shortest string that has both as subsequences. Constraints: 1 <= str1.length, str2....
Count Vowels Permutation (统计元音字母序列的数目)
Count the number of strings of length n over the vowels a, e, i, o, u such that each character is followed only by allowed letters...
Burst Balloons (戳气球)
Given nums representing balloons, bursting balloon i yields nums[i-1] * nums[i] * nums[i+1] coins, where out-of-range neighbours c...
Number of Ways to Rearrange Sticks With K Sticks Visible (恰有 K 根木棍可以看到的排列数目)
There are n sticks of distinct heights 1 to n. Count the permutations in which exactly k sticks are visible when viewed from the l...
Regular Expression Matching (正则表达式匹配)
Given an input string s and a pattern p supporting . (any single character) and * (zero or more of the preceding element), return ...
Flip String to Monotone Increasing (将字符串翻转到单调递增)
Given a binary string s, return the minimum number of flips so that the string becomes monotone increasing (some prefix of zeros f...