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.
Campus Bikes (校园自行车分配)
Given workers and bikes coordinates on a grid, assign each worker a distinct bike minimising the total Manhattan distance, with ti...
Rearrange String k Distance Apart (K 距离间隔重排字符串)
Given a string s and an integer k, rearrange it so that the same characters are at least k positions apart. Return any valid arran...
K Closest Points to Origin (最接近原点的 K 个点)
Given an array of points and an integer k, return the k closest points to the origin, in any order. Constraints: 1 <= k <= p...
Kth Largest Element in an Array (数组中的第 K 个最大元素)
Given an integer array nums and an integer k, return the k-th largest element. Constraints: 1 <= k <= nums.length <= 10^5...
Task Scheduler (任务调度器)
You are given a list of CPU tasks (letters) and a cooldown n. Identical tasks must be separated by at least n intervals; idle slot...
Design Twitter (设计推特)
Design a simplified Twitter with postTweet, getNewsFeed (the 10 most recent tweets from the user and their followees), follow and ...
Least Number of Unique Integers after K Removals (不同整数的最少数目)
Given an integer array arr and an integer k, remove exactly k elements so that the number of distinct remaining integers is minimi...
Furthest Building You Can Reach (可以到达的最远建筑)
You are given heights of buildings, bricks and ladders. Moving from building i to i + 1 requires the height difference in bricks, ...
Minimize Deviation in Array (最小化数组中的最大值)
You are given an array nums of positive integers. You may divide any even number by 2, or multiply any odd number by 2, any number...
Maximum Subsequence Score (最大子序列的分数)
You are given two arrays nums1 and nums2 of equal length, and an integer k. Choose k indices; the score is (sum of nums1 at those ...
Single-Threaded CPU (单线程 CPU)
You are given tasks where tasks[i] = [enqueueTime, processingTime]. A single-threaded CPU picks, at each idle moment, the availabl...
Seat Reservation Manager (座位预约管理系统)
Design a seat reservation manager for seats numbered 1..n. reserve() returns the smallest unreserved seat and marks it reserved; u...
Process Tasks Using Servers (使用服务器处理任务)
You are given servers (where servers[i] is the weight of server i) and tasks (where tasks[j] is the time to process task j). Task ...
Find the Kth Largest Integer in the Array (找出数组中的第 K 大整数)
You are given an array of strings nums representing integers without leading zeros, and an integer k. Return the string representi...
Reorganize String (重构字符串)
Given a string s, rearrange its characters so that no two adjacent characters are the same. Return any valid arrangement, or the e...
Longest Happy String (最长快乐字符串)
A happy string consists of a, b, c with no three consecutive identical characters. Given counts a, b, c, return the longest possib...
Car Pooling (拼车)
A car travels east; trips[i] = [numPassengers, from, to] describes a trip. Given capacity, return whether all trips can be complet...
Range Sum of Sorted Subarray Sums (子数组和排序后的区间和)
Given an array nums of n positive integers and integers left and right, consider all n(n+1)/2 subarray sums, sort them ascending, ...
Maximum Transactions Without Negative Balance (最大交易次数(无负余额))
You are given an array transactions of costs and an initial balance. You may process the transactions in any order, but the runnin...
Path With Maximum Minimum Value (得分最高的路径)
Given an m x n integer matrix grid, return the maximum possible score of a path from the top-left to the bottom-right corner, wher...
Find Median from Data Stream (数据流的中位数)
Design a data structure supporting addNum(num) and findMedian(). Constraints: -10^5 <= num <= 10^5; at most 5 * 10^4 calls.
Maximum Performance of a Team (最大的团队表现值)
You are given n engineers with speed[i] and efficiency[i]. Choose at most k engineers to maximise (sum of speeds) * (minimum effic...
IPO (IPO)
You have k initial capital w and n projects with profits[i] and capital[i]. You may start at most k projects, each requiring the a...
Minimum Cost to Hire K Workers (雇佣 K 名工人的最低成本)
There are n workers with quality[i] and a minimum expected wage wage[i]. Hire exactly k workers and pay each the same amount per u...