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.
Concatenation of Array (数组串联)
Given an integer array nums of length n, build an array ans of length 2n where ans[i] == nums[i] and ans[i + n] == nums[i] for 0 &...
Contains Duplicate (存在重复元素)
Given an integer array nums, return true if any value appears at least twice, and false if every element is distinct. Constraints:...
Valid Anagram (有效的字母异位词)
Given two strings s and t, return true if t is an anagram of s, and false otherwise. Constraints: 1 <= s.length, t.length <=...
Replace Elements with Greatest Element on Right Side (将每个元素替换为右侧最大元素)
Given an array arr, replace every element with the greatest element among the elements to its right, and replace the last element ...
Is Subsequence (判断子序列)
Given two strings s and t, return true if s is a subsequence of t. A subsequence is formed by deleting some characters without cha...
Append Characters to String to Make Subsequence (追加字符以获得子序列)
Given strings s and t, return the minimum number of characters that must be appended to s so that t becomes a subsequence of s. Co...
Score of a String (字符串的分数)
Given a string s, return the score of the string: the sum of |s[i] - s[i+1]| over all adjacent pairs, using the alphabetical posit...
Length of Last Word (最后一个单词的长度)
Given a string s consisting of words and spaces, return the length of the last word. A word is a maximal substring of non-space ch...
Valid Word Square (有效的单词方阵)
Given an array of strings words, return true if it forms a valid word square: for every valid index pair (i, j), words[i][j] == wo...
Confusing Number (易混淆数)
A confusing number is one that becomes a different valid number when rotated 180 degrees. The valid digits are 0, 1, 6, 8, 9, whic...
Find Anagram Mappings (找出变位映射)
Given two arrays nums1 and nums2 that are anagrams of each other, return a mapping array mapping where mapping[i] == j means nums2...
Sentence Similarity (句子相似性)
Given two sentences sentence1 and sentence2 as arrays of words, and a list of similarPairs of words, determine whether the two sen...
Largest Unique Number (最大唯一数)
Given an integer array nums, return the largest integer that only occurs once. If no integer occurs exactly once, return -1. Const...
Single-Row Keyboard (单行键盘)
A robot has one finger and types on a single-row keyboard. It starts with the finger on the key at index 0. Given keyboard (a perm...
Palindrome Permutation (回文排列)
Given a string s, return true if a permutation of s could form a palindrome. Constraints: 1 <= s.length <= 5000; s consists ...
Counting Elements (数元素)
Given an integer array arr, count how many elements x exist such that x + 1 is also present in arr. If duplicates of x exist, coun...
Perform String Shifts (字符串的左右移)
You are given a string s and a 2D array shift where shift[i] = [direction, amount]. Direction 0 means shift left by amount, direct...
Design Compressed String Iterator (迭代压缩字符串)
Design and implement an iterator over a run-length encoded string, supporting next() (return the next character, or a single space...
Logger Rate Limiter (日志速率限制器)
Design a logger that only prints a message if it has not been printed in the last 10 seconds. Implement shouldPrintMessage(timesta...
Group Shifted Strings (移位字符串分组)
Given a list of strings where all strings are of the same length, group all strings that belong to the same shifting sequence. A s...
Moving Average from Data Stream (数据流中的移动平均值)
Design a class that computes the moving average of the last size values from a stream of integers, exposing a next(val) method tha...
Maximum Distance in Arrays (数组列表中的最大距离)
You are given m arrays, each sorted in ascending order. Pick exactly one integer from two different arrays and maximise |a - b|. R...
Lonely Pixel I (孤独像素 I)
Given an m x n picture consisting of black 'B' and white 'W' pixels, return the number of lonely black pixels. A black pixel at (i...
Sparse Matrix Multiplication (稀疏矩阵的乘法)
Given two sparse matrices mat1 of size m x k and mat2 of size k x n, return the result of mat1 x mat2. You may assume the multipli...