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.
Minimum Operations to Make Binary Array Elements Equal to One I (使二进制数组全部等于 1 的最少操作次数 I)
Given a binary array nums, an operation chooses an index i <= n - 3 and flips nums[i], nums[i+1] and nums[i+2]. Return the mini...
Buildings With an Ocean View (能看到海景的建筑物)
There is a row of buildings with heights heights, and the ocean is to the right. A building has an ocean view if every building to...
Minimum Length of String After Operations (操作后字符串的最短长度)
Given a string s, an operation picks an index i and a character c equal to s[i] that appears both to the left and to the right of ...
Construct K Palindrome Strings (构造 K 个回文字符串)
Given a string s and an integer k, return true if you can use all the characters of s to construct exactly k palindrome strings. C...
Separate Black and White Balls (区分黑球与白球)
You are given a binary string s where 1 is a black ball and 0 is a white ball. In one operation you may swap two adjacent balls. R...
Minimum Increment to Make Array Unique (使数组唯一的最小增量)
Given an integer array nums, in one move you may increment any element by 1. Return the minimum number of moves to make every valu...
Maximum Subarray (最大子数组和)
Given an integer array nums, find the contiguous subarray (containing at least one number) with the largest sum and return that su...
Maximum Absolute Sum of Any Subarray (任意子数组和的绝对值的最大值)
Given an integer array nums, return the maximum absolute sum of any subarray (the subarray may be empty, giving 0). Constraints: 1...
Maximum Sum Circular Subarray (环形子数组的最大和)
Given a circular integer array nums, return the maximum possible sum of a non-empty subarray of the circular array. Constraints: 1...
Minimum Swaps to Group All 1's Together II (最少交换次数来组合所有的 1 II)
Given a circular binary array nums, return the minimum number of swaps to group all the 1s together at any location. Constraints: ...
Longest Turbulent Subarray (最长湍流子数组)
A subarray is turbulent if the comparison sign between adjacent elements alternates (<, >, <, ... or >, <, >, .....
Jump Game (跳跃游戏)
You are given an integer array nums and start at index 0. Each element nums[i] is the maximum jump length from that position. Retu...
Jump Game II (跳跃游戏 II)
Given a 0-indexed array nums where nums[i] is the maximum jump length from index i, return the minimum number of jumps to reach th...
Jump Game VII (跳跃游戏 VII)
Given a 0-indexed binary string s, and integers minJump and maxJump, you start at index 0 and may jump from i to j if s[j] == '0' ...
Gas Station (加油站)
There are n gas stations in a circle; gas[i] is the fuel available and cost[i] is the fuel to travel to the next station. Starting...
Hand of Straights (一手顺子)
Alice has a hand of cards hand and wants to rearrange them into groups of groupSize consecutive cards. Return true if she can. Con...
Minimum Number of Changes to Make Binary String Beautiful (使二进制字符串变美丽的最少修改次数)
Given an even-length binary string s, it is beautiful if it can be split into one or more even-length substrings, each with an equ...
Minimize Maximum of Array (最小化数组中的最大值)
Given an array nums of n non-negative integers, an operation chooses an index i in [1, n-1], decreases nums[i] by 1 and increases ...
Maximize Y‑Sum by Picking a Triplet of Distinct X‑Values (最大化 X 值三元组的 Y 值和)
You are given two integer arrays x and y of the same length n. Choose three indices i, j, k with distinct x values so that y[i] + ...
Minimum Difference Between Largest and Smallest Value in Three Moves (三次操作后最大值与最小值的最小差值)
Given an array nums, in one move you may change any element to any value. Return the minimum difference between the largest and sm...
Maximum Total Importance of Roads (道路的最大总重要性)
You are given an integer n (cities numbered 0..n-1) and roads where roads[i] = [a, b] is a bidirectional road. Assign each city a ...
Minimum Number of Pushes to Type Word II (输入单词需要的最少按键次数 II)
You are given a string word. You may remap letters to the eight keys labelled 2 to 9; the cost to type a letter is its position on...
Dota2 Senate (Dota2 参议院)
In the Dota2 senate, each senator is from the Radiant or Dire party. In each round, senators act in order; each may ban one opposi...
Maximum Points You Can Obtain from Cards (可获得的最大点数)
There are several cards in a row with cardPoints[i] points. In each step you take one card from either the beginning or the end. Y...