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.
Naming a Company (公司命名)
You are given an array of distinct strings ideas, each of length 2. A company name is formed by swapping the first letters of two ...
Number of Submatrices That Sum to Target (元素和为目标值的子矩阵数量)
Given a matrix and a target, return the number of non-empty submatrices whose sum equals target. Constraints: 1 <= m, n <= 1...
First Missing Positive (缺失的第一个正数)
Given an unsorted integer array nums, return the smallest positive integer that is not present in nums. Constraints: 1 <= nums....
Shortest Palindrome (最短回文串)
You are given a string s. You can convert it to a palindrome by adding characters in front of it. Return the shortest palindrome y...
Number of Ships in a Rectangle (矩形内船只的数目)
This is an interactive problem. A Sea object has a hasShips(topRight, bottomLeft) method returning whether any ship exists in the ...
Time Taken to Cross the Door (通过门的时间)
There are n people who want to cross a door. arrival[i] is the arrival time and state[i] is 0 for entering, 1 for exiting. Each pe...
Design Excel Sum Formula (设计 Excel 求和公式)
Design a simplified Excel with set(row, column, val), get(row, column) and sum(row, column, numbers) where numbers is a list of ce...
Reverse String (反转字符串)
Write a function that reverses a character array s in place. You must do it with O(1) extra memory. Constraints: 1 <= s.length ...
Valid Palindrome (验证回文串)
A phrase is a palindrome if, after converting all uppercase letters to lowercase and removing all non-alphanumeric characters, it ...
Valid Palindrome II (验证回文串 II)
Given a string s, return true if it can become a palindrome by deleting at most one character. Constraints: 1 <= s.length <=...
Valid Word Abbreviation (有效单词缩写)
A string can be abbreviated by replacing any number of non-adjacent, non-empty substrings with their lengths. Given a string word ...
Merge Strings Alternately (交替合并字符串)
You are given two strings word1 and word2. Merge them by adding letters in alternating order, starting with word1. If one string i...
Merge Sorted Array (合并两个有序数组)
You are given two sorted integer arrays nums1 and nums2 and two integers m and n, where nums1 has length m + n with the first m el...
Merge Two 2D Arrays by Summing Values (合并两个二维数组 - 求和法)
You are given two 2D integer arrays nums1 and nums2, each [id_i, val_i], sorted by id with distinct ids. Merge them by summing the...
Move Zeroes (移动零)
Given an integer array nums, move all 0s to the end while maintaining the relative order of the non-zero elements, in place. Const...
Remove Duplicates from Sorted Array (删除有序数组中的重复项)
Given an integer array nums sorted in non-decreasing order, remove the duplicates in place so each element appears once, and retur...
Squares of a Sorted Array (有序数组的平方)
Given an integer array nums sorted in non-decreasing order, return an array of the squares of each number, also sorted in non-decr...
Assign Cookies (分发饼干)
You have children with greed factors g and cookies with sizes s. Each child gets at most one cookie, and a child is content if the...
Find First Palindromic String in the Array (找出数组中的第一个回文字符串)
Given an array of strings words, return the first palindromic string. If there is no such string, return an empty string. Constrai...
Sort Array By Parity (按奇偶排序数组)
Given an integer array nums, move all even integers to the beginning followed by all odd integers, and return any array satisfying...
Reverse Words in a String III (反转字符串中的单词 III)
Given a string s, reverse the order of characters in each word while keeping the word order and the single spaces between words. C...
Backspace String Compare (比较含退格的字符串)
Given two strings s and t where # represents a backspace, return whether they are equal after processing all backspaces. A # on an...
Check If Two String Arrays are Equivalent (检查两个字符串数组是否相等)
Given two string arrays word1 and word2, return whether the two arrays represent the same string when concatenated. Constraints: 1...
Apply Operations to an Array (对数组执行操作)
You are given a 0-indexed array nums of non-negative integers. For each index i from 0 to n-2: if nums[i] == nums[i+1], multiply n...