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.
Sqrt(x) (x 的平方根)
Given a non-negative integer x, return the square root of x rounded down to the nearest integer. You must not use any built-in exp...
Missing Number In Arithmetic Progression (等差子数组中的缺失数字)
Given an array arr that was originally an arithmetic progression with a missing element, return the missing value. The progression...
Check If a Number Is Majority Element in a Sorted Array (检查一个数是否在数组中占绝大多数)
Given an integer array nums sorted in non-decreasing order and an integer target, return true if target is the majority element (a...
Missing Element in Sorted Array (有序数组中的缺失元素)
Given an integer array nums sorted ascending with distinct values and an integer k, return the k-th missing number starting from n...
Find the Index of the Large Integer (找出数组中的大整数下标)
This is an interactive problem. An array of n integers has one element strictly larger than all others. ArrayReader.compareSub(l1,...
Divide Chocolate (分享巧克力)
You have one chocolate bar with pieces of sweetness sweetness[i]. You will share it with k friends, so you cut the bar into k + 1 ...
Maximum Average Subarray II (最大平均子段和 II)
You are given an array nums of integers and an integer k. Find a contiguous subarray of length at least k with the maximum average...
Single Element in a Sorted Array (有序数组中的单一元素)
You are given a sorted array of integers where every element appears exactly twice except one element which appears once. Return t...
Find Peak Element (寻找峰值)
A peak element is one strictly greater than its neighbours. Given an integer array nums, return the index of any peak. Assume nums...
Successful Pairs of Spells and Potions (咒语和药水的成功对数)
You are given two positive integer arrays spells and potions, and an integer success. A spell and a potion form a successful pair ...
Search a 2D Matrix (搜索二维矩阵)
You are given an m x n integer matrix with two properties: each row is sorted left to right, and the first integer of each row is ...
Koko Eating Bananas (爱吃香蕉的珂珂)
Koko has piles of bananas and h hours. Each hour she chooses a pile and eats k bananas from it; if the pile has fewer than k left,...
Capacity To Ship Packages Within D Days (在 D 天内送达包裹的能力)
A conveyor belt has packages with weights weights[i] that must be shipped within days days, in the given order. Each day a ship ca...
Maximum Candies Allocated to K Children (分配给 K 个孩子的最大糖果数)
You are given a 0-indexed integer array candies where candies[i] is the number of candies in the i-th pile, and an integer k. Each...
House Robber IV (打家劫舍 IV)
You are given an integer array nums and an integer k. You must rob at least k houses; adjacent houses cannot both be robbed. The c...
Minimize the Maximum Difference of Pairs (最小化数对的最大差值)
You are given a 0-indexed integer array nums and an integer p. Find p pairs of indices such that no index appears in more than one...
Minimized Maximum of Products Distributed to Any Store (分配给商店的最多商品的最小值)
You are given n stores and an array quantities where quantities[i] is the number of products of type i. You must distribute all pr...
Minimum Limit of Balls in a Bag (袋子里最少数目的球)
You are given an integer array nums where nums[i] is the number of balls in the i-th bag, and an integer maxOperations. Each opera...
Minimum Time to Repair Cars (修车的最少时间)
You are given an integer array ranks where ranks[i] is the rank of the i-th mechanic, and an integer cars. A mechanic with rank r ...
Find Minimum in Rotated Sorted Array (寻找旋转排序数组中的最小值)
Suppose an array of distinct integers sorted ascending is rotated between 1 and n times. Given the rotated array nums, return its ...
Search in Rotated Sorted Array (搜索旋转排序数组)
Given a rotated sorted array of distinct integers nums and a target, return the index of target or -1. Constraints: 1 <= nums.l...
Search in Rotated Sorted Array II (搜索旋转排序数组 II)
Given a rotated sorted array nums that may contain duplicates, and a target, return whether the target exists in the array. Constr...
Time Based Key-Value Store (基于时间的键值存储)
Design a time-based key-value store supporting set(key, value, timestamp) and get(key, timestamp), which returns the value with th...
Find First and Last Position of Element in Sorted Array (在排序数组中查找元素的第一个和最后一个位置)
Given an array of integers nums sorted in non-decreasing order and a target, return the starting and ending position of the target...