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.
Max Chunks To Make Sorted (最多能完成排序的块)
You are given an array arr that is a permutation of 0 .. n-1. Split the array into some number of contiguous chunks and sort each ...
Next Permutation (下一个排列)
A permutation of integers is given as nums. Rearrange it in place into the next permutation in lexicographic order. If no larger p...
Maximum Swap (最大交换)
You are given an integer num. You may swap two digits at most once to get the maximum valued number. Return the maximum value you ...
Maximal Score After Applying K Operations (执行 K 次操作后的最大分数)
You are given an integer array nums and an integer k. In one operation, choose an index i, add nums[i] to your score, then replace...
Maximum Frequency After Subarray Operation (子数组操作后的最大频率)
You are given an integer array nums and an integer k. Choose one contiguous subarray and add k to every element in it. Return the ...
Put Boxes Into the Warehouse I (把箱子放进仓库里 I)
You are given boxes, the heights of unit-width boxes, and warehouse, the heights of rooms in a warehouse. Boxes are pushed in from...
Put Marbles in Bags (将珠子放入背包中)
You are given an array weights and an integer k. Split the array into k contiguous groups; the score of a group is the sum of its ...
Minimum Number of K Consecutive Bit Flips (K 连续位的最小翻转次数)
You are given a binary array nums and an integer k. In one operation, choose a window of length k (starting at i with i + k <= ...
Maximum Score of a Good Subarray (好子数组的最大分数)
You are given an array nums and an integer k. A good subarray is one that contains index k. The score of a subarray is its minimum...
Find the Maximum Sum of Node Values (最大节点价值之和)
You are given a tree with n nodes, an array nums of node values, an integer k, and edges describing the tree. In one operation, ch...
Minimum Number of Increments on Subarrays to Form a Target Array (形成目标数组的子数组最少增加次数)
You are given an integer array target. Starting from an array of zeros, in one operation you choose a subarray and increment every...
Apply Operations to Maximize Score (操作使得分最大)
You are given an array nums and an integer k. The prime score of a number is its count of distinct prime factors. In one operation...
Missing Ranges (缺失的区间)
You are given a sorted integer array nums with distinct values and inclusive bounds lower and upper. Return the list of missing ra...
Remove Interval (删除区间)
You are given a sorted list of disjoint intervals intervals and an interval toBeRemoved. Return the list of intervals after removi...
Add Bold Tag in String (给字符串添加加粗标签)
You are given a string s and a list of words. Wrap in <b> and </b> every substring of s that matches any word, merging...
Insert Interval (插入区间)
You are given an array of non-overlapping intervals intervals, sorted by start, and a newInterval. Insert newInterval and merge an...
Merge Intervals (合并区间)
You are given an array of intervals intervals. Merge all overlapping intervals and return the non-overlapping intervals that cover...
Non-overlapping Intervals (无重叠区间)
You are given an array of intervals intervals. Return the minimum number of intervals you must remove to make the rest non-overlap...
Interval List Intersections (区间列表的交集)
You are given two lists of closed intervals firstList and secondList, each sorted and internally disjoint. Return the intersection...
Meeting Rooms (会议室)
You are given an array of meeting time intervals intervals. Determine whether a person could attend all meetings, i.e. no two inte...
Meeting Rooms II (会议室 II)
You are given an array of meeting time intervals intervals. Return the minimum number of conference rooms required to hold all mee...
Meeting Rooms III (会议室 III)
You are given n rooms numbered 0 to n-1 and a list of meetings [start, end]. Rooms are assigned to the lowest-numbered free room; ...
Divide Intervals Into Minimum Number of Groups (将区间分为最少组数)
You are given a 2D array intervals. Divide the intervals into the minimum number of groups such that no two intervals in the same ...
Remove Covered Intervals (删除被覆盖区间)
You are given an array of intervals intervals. Remove all intervals that are covered by another interval (an interval [a, b] is co...