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.
Maximum Value of K Coins From Piles (从栈中取出 K 个硬币的最大面值和)
There are piles of coins; piles[i][j] is the value of the j-th coin from the top of pile i. You take exactly k coins, and from any...
Number of Music Playlists (播放列表的数量)
You build a playlist of length goal from n distinct songs. Every song must be played at least once, and a song may repeat only if ...
Number of Ways to Form a Target String Given a Dictionary (通过给定词典构造目标字符串的方案数)
Given a list of equal-length words and a target string, count the number of ways to form target by picking, for each position k, a...
Profitable Schemes (盈利计划)
There are n members available. Crime i needs group[i] members and yields profit[i]. Choose a subset of crimes whose total members ...
Minimum Cost to Cut a Stick (切棍子的最小成本)
A wooden stick of length n has cut positions cuts. Each cut costs the length of the stick being cut at that moment. Return the min...
Painting the Walls (给墙壁刷油漆)
You must paint n walls. A paid painter paints wall i in time[i] units and charges cost[i]; while the paid painter is busy, a free ...
Number of Ways to Stay in the Same Place After Some Steps (停在原地的方案数)
An array has length arrLen and a pointer starts at index 0. Each step the pointer moves left, right, or stays put, and it must rem...
String Compression II (压缩字符串 II)
Run-length encoding replaces a run of L identical characters c with c if L == 1, else c followed by the decimal digits of L. Given...
Minimum Difficulty of a Job Schedule (工作计划的最低难度)
You have jobDifficulty and d days. Split the jobs, in the given order, into exactly d non-empty consecutive groups. A day's diffic...
Arithmetic Slices II - Subsequence (等差数列划分 II - 子序列)
Given an integer array nums, return the number of arithmetic subsequences of length at least 3. Constraints: 1 <= nums.length &...
K Inverse Pairs Array (K 个逆序对数组)
Given n and k, count the permutations of the integers 1 to n that have exactly k inverse pairs, modulo 1e9+7. An inverse pair is a...
Cherry Pickup (摘樱桃)
Given an n x n grid where 0 is empty, 1 is a cherry, and -1 is a thorn (blocked), start at (0, 0), walk to (n-1, n-1) moving only ...
Cherry Pickup II (摘樱桃 II)
Given a rows x cols grid of cherries, two robots start at (0, 0) and (0, cols-1). Each step both move down one row, to a column wi...
Minimum Falling Path Sum II (下降路径最小和 II)
Given an n x n grid, a falling path picks one cell per row, and the column chosen in row r + 1 must differ from the column chosen ...
Freedom Trail (自由之路)
The string ring is written around a dial with index 0 at the top, and a center button can be pressed. To spell key, rotate the rin...
Split Array With Same Average (数组的均值分割)
Given an integer array nums, return true if it can be split into two non-empty subsets whose averages are equal. Constraints: 1 &l...
Paint House II (粉刷房子 II)
There are n houses in a row and k colours. Painting house i with colour j costs costs[i][j], and no two adjacent houses may share ...
Buy Two Chocolates (购买两块巧克力)
You are given an integer array prices and an integer money. You must buy exactly two distinct chocolates. Return the money left af...
Lemonade Change (柠檬水找零)
Each customer in a queue pays with a 5, 10 or 20 dollar bill for a 5 dollar lemonade. You start with no change. Return true if you...
Minimum Number of Moves to Seat Everyone (使每位学生都有座位的最少移动次数)
There are n seats and n students. seats[i] is the position of the i-th seat and students[j] the position of the j-th student. Each...
Maximum Odd Binary Number (最大二进制奇数)
You are given a binary string s containing at least one 1. Rearrange its bits to form the maximum odd binary number (a binary stri...
Maximum Nesting Depth of the Parentheses (括号的最大嵌套深度)
A string s is a valid parentheses string (VPS) if it is empty, or (A) or AB for VPS A and B, and contains no other characters. Ret...
Check if One String Swap Can Make Strings Equal (仅执行一次字符串交换能否使两个字符串相等)
You are given two strings s1 and s2 of equal length. You may swap exactly two characters at indices i and j (possibly i == j) in o...
How Many Apples Can You Put into the Basket (最多可以买到的苹果数量)
You are given an array weight where weight[i] is the weight of the i-th apple. A basket can hold at most 5000 units. Return the ma...