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.
Longest Strictly Increasing or Strictly Decreasing Subarray (最长的严格递增或递减子数组)
Given an array of integers nums, return the length of the longest subarray that is either strictly increasing or strictly decreasi...
Maximum Ascending Subarray Sum (最大升序子数组和)
Given an array of positive integers nums, return the maximum possible sum of an ascending subarray: a contiguous run of elements w...
Find Pivot Index (寻找数组的中心下标)
Given an array of integers nums, return the leftmost pivot index where the sum of all elements strictly to the left equals the sum...
Kth Distinct String in an Array (数组中第 K 个独一无二的字符串)
A distinct string is one that appears exactly once in an array. Given an array of strings arr and an integer k, return the k-th di...
Range Sum Query - Immutable (区域和检索 - 数组不可变)
Design a class that answers sum queries on an immutable array. Implement NumArray(nums) and sumRange(left, right), returning the s...
Find All Numbers Disappeared in an Array (找到所有数组中消失的数字)
Given an array nums of n integers where each element is in the range [1, n], return an array of all the integers in [1, n] that do...
Find Missing and Repeated Values (找出缺失和重复的数字)
You are given an n x n grid where every integer from 1 to n^2 appears exactly once, except that one value is repeated and one is m...
Maximum Number of Balloons ("气球"的最大数量)
Given a string text of lowercase letters, return the maximum number of instances of the word "balloon" that can be formed using th...
Word Pattern (单词规律)
Given a pattern string and a string s, determine whether s follows the same pattern: each letter of pattern must map bijectively t...
Design HashSet (设计哈希集合)
Design a HashSet without using any built-in hash table libraries. Implement add(key), remove(key) and contains(key). Constraints: ...
Design HashMap (设计哈希映射)
Design a HashMap without using any built-in hash table libraries. Implement put(key, value), get(key) and remove(key). Constraints...
Height Checker (高度检查器)
Students are asked to stand in non-decreasing order of height. Given the current order in heights, return the number of indices wh...
Find Lucky Integer in an Array (找出数组中的幸运数)
Given an array of integers arr, a lucky integer is one whose value equals its frequency in the array. Return the largest lucky int...
Special Array I (特殊数组 I)
An array is special if the parity of every adjacent pair of elements differs. Given an integer array nums, return true if it is sp...
Check if Array Is Sorted and Rotated (检查数组是否经排序和轮转得到)
Given an array nums, return true if it was originally sorted in non-decreasing order and then rotated some number of positions (in...
Monotonic Array (单调数列)
An array is monotonic if it is either non-increasing or non-decreasing. Given an integer array nums, return true if it is monotoni...
Divide Array Into Equal Pairs (将数组划分成相等数对)
You are given an integer array nums of even length. Divide it into n / 2 pairs so that every pair contains two equal elements. Ret...
Number of Good Pairs (好数对的数目)
Given an array of integers nums, return the number of good pairs (i, j) with i < j and nums[i] == nums[j]. Constraints: 1 <=...
Pascal's Triangle II (杨辉三角 II)
Given an integer rowIndex, return the rowIndex-th (0-indexed) row of Pascal's triangle. Constraints: 0 <= rowIndex <= 33. Th...
Find Words That Can Be Formed by Characters (拼写单词)
You are given an array of strings words and a string chars. A string is good if it can be formed using only the letters of chars, ...
Count the Number of Consistent Strings (统计一致字符串的数目)
You are given a string allowed of distinct characters and an array of strings words. A string is consistent if every character in ...
Ransom Note (赎金信)
Given two strings ransomNote and magazine, return true if ransomNote can be constructed using the letters of magazine, each used a...
Largest 3-Same-Digit Number in String (字符串中最大的 3 位相同数字)
You are given a string num representing a large integer. Return the largest three-digit substring of num that consists of the same...
Destination City (旅行终点站)
You are given an array paths where paths[i] = [cityA, cityB] means there is a direct path from cityA to cityB. Return the destinat...