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.
Distribute Candies Among Children II (给小朋友们分糖果 II)
Given two positive integers n and limit, count the ways to distribute n identical candies among 3 children so that no child receiv...
Line Reflection (直线镜像)
Given n integer points points[i] = [xi, yi], determine whether a line parallel to the y-axis exists such that reflecting every poi...
Minimum Factorization (最小因式分解)
Given a positive integer a, find the smallest positive integer b whose digit product equals a. Return 0 if no such b exists or if ...
Minimum One Bit Operations to Make Integers Zero (使整数变为 0 的最少操作次数)
Given an integer n, the allowed operations are: (1) flip the lowest bit (bit 0); (2) flip bit i for any i >= 1 provided bit i i...
K-th Smallest in Lexicographical Order (字典序的第 K 小数字)
Given integers n and k, return the k-th number in the lexicographical ordering of the integers 1..n. Constraints: 1 <= k <= ...
Integer to English Words (整数转换英文表示)
Given a non-negative integer num, return its English words representation following standard American grouping, so 123 becomes One...
Best Meeting Point (最佳的碰头地点)
Given an m x n binary grid, find a meeting point at any integer coordinate that minimises the total Manhattan distance to every ce...
Create Hello World Function (创建 Hello World 函数)
Return a function f that always returns the string Hello World when called, ignoring any arguments it receives. Constraints: 0 <...
Counter (计数器)
Given an integer n, return a counter function. The first call returns n, and every subsequent call returns one more than the previ...
Counter II (计数器 II)
Given an initial value init, return an object with three methods: increment (adds 1 and returns the current value), decrement (sub...
Apply Transform Over Each Element in Array (转换数组中的每个元素)
Given an integer array arr and a function fn, return a new array res where res[i] = fn(arr[i], i). The built-in Array.map must not...
Filter Elements from Array (过滤数组中的元素)
Given an integer array arr and a function fn, return a new array containing only the elements for which fn(arr[i], i) is truthy. T...
Array Reduce Transformation (数组归约运算)
Given an integer array nums, a reducer fn, and an initial value init, return fn(...fn(fn(init, nums[0]), nums[1]), ...). The built...
Function Composition (函数组合)
Given an array of functions functions, return a new function fn(x) whose result is the right-to-left composition of all of them. F...
Allow One Function Call (只允许一次函数调用)
Given a function fn, return a wrapper that executes fn and returns its result on the first call, and returns undefined on every su...
Memoize (记忆函数)
Implement memoize(fn), returning a cached version of fn. If the function has already been called with the same arguments, return t...
Curry (柯里化)
Given a function fn, return its curried version: it may be called with one argument at a time or several at once, and it executes ...
Sleep (睡眠函数)
Implement sleep(millis), which returns a Promise that resolves after millis milliseconds. It enables await sleep(100) to pause an ...
Promise Time Limit (有时间限制的 Promise)
Given an asynchronous function fn and a time limit t in milliseconds, return a wrapper: if fn(...args) settles within t millisecon...
Promise Pool (任务调度器)
Given an array of asynchronous functions functions and a concurrency limit n, return a Promise that resolves once all of them have...
Cache With Time Limit (有时间限制的缓存)
Implement a TimeLimitedCache class: set(key, value, duration) stores an entry and returns whether the key already existed and was ...
Debounce (防抖)
Implement debounce(fn, t): return a wrapper that, after a burst of calls, invokes fn once only after t milliseconds of silence, us...
Throttle (节流)
Implement throttle(fn, t): return a wrapper that invokes fn at most once in any window of t milliseconds; a call suppressed inside...
JSON Deep Equal (完全相等的 JSON 对象)
Given two objects o1 and o2, return whether they are deeply equal: every key and value matches recursively, arrays must have equal...