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.
Image Smoother (图片平滑器)
Given an m x n integer matrix img representing an image, return the smoothed image in which each cell becomes the floor of the ave...
Count of Matches in Tournament (比赛中的配对次数)
In a tournament with n teams, teams are paired each round; the winner advances and the loser is eliminated, until a single champio...
Water Bottles (换水问题)
You start with numBottles full water bottles. You may exchange numExchange empty bottles for one full bottle. Return the maximum n...
Largest Local Values in a Matrix (矩阵中的局部最大值)
Given an n x n integer matrix grid, return an (n - 2) x (n - 2) matrix where each entry is the maximum value in the corresponding ...
Power of Four (4 的幂)
Given an integer n, return true if it is a power of four, otherwise false. Constraints: -2^31 <= n <= 2^31 - 1.
Lucky Numbers in a Matrix (矩阵中的幸运数)
Given an m x n matrix of distinct integers, return all lucky numbers in any order. A lucky number is an element that is the minimu...
Armstrong Number (阿姆斯特朗数)
Given an integer n, return true if it is an Armstrong number: the sum of each of its digits raised to the power of the number of d...
Count Substrings with Only One Distinct Letter (统计只含单一字母的子串)
Given a string s, return the number of substrings that contain only one distinct letter, meaning every character in the substring ...
Guess the Majority in a Hidden Array (找出隐藏数组中出现次数最多的值)
This is an interactive problem, so it cannot be run offline: the hidden binary array is only reachable through the provided ArrayR...
Maximum Number of Ones (矩阵中 1 的最大数量)
You are given the dimensions width and height of a binary matrix, a window size sideLength, and maxOnes. Place ones so that every ...
Max Points on a Line (直线上最多的点数)
Given an array points where points[i] = [xi, yi] represents a point on the X-Y plane, return the maximum number of points that lie...
Magic Squares In Grid (矩阵中的幻方)
A 3x3 magic square contains each of the integers 1 to 9 exactly once, and every row, every column and both diagonals sum to the sa...
Rotate Image (旋转图像)
You are given an n x n 2D matrix representing an image. Rotate the image by 90 degrees clockwise, in place (do not allocate anothe...
Spiral Matrix (螺旋矩阵)
Given an m x n matrix, return all of its elements in spiral order, starting at the top-left and moving clockwise inward. Constrain...
Spiral Matrix II (螺旋矩阵 II)
Given a positive integer n, generate an n x n matrix filled with the numbers 1 through n^2 arranged in spiral order, starting at t...
Spiral Matrix III (螺旋矩阵 III)
Starting at (rStart, cStart) in a rows x cols grid, walk clockwise in a spiral: east, south, west, north, then east again, expandi...
Spiral Matrix IV (螺旋矩阵 IV)
Given two integers m and n and the head of a singly linked list, fill an m x n matrix with the list's values in spiral order, star...
Set Matrix Zeroes (矩阵置零)
Given an m x n integer matrix, if an element is 0, set its entire row and column to 0, modifying the matrix in place. Constraints:...
Happy Number (快乐数)
A happy number is a number that eventually reaches 1 when repeatedly replaced by the sum of the squares of its decimal digits; an ...
Plus One (加一)
Given a non-empty array digits of decimal digits representing a non-negative integer with the most significant digit first and no ...
Palindrome Number (回文数)
Given an integer x, return true if x reads the same forwards and backwards, otherwise false. Constraints: -2^31 <= x <= 2^31...
Ugly Number (丑数)
An ugly number is a positive integer whose prime factors are limited to 2, 3 and 5. Given an integer n, return true if it is ugly,...
Convert 1D Array Into 2D Array (将一维数组转变成二维数组)
Given a 1D array original and two integers m and n, build an m x n 2D array by filling it row by row with the elements of original...
Shift 2D Grid (二维网格迁移)
Given an m x n grid and an integer k, shift the grid k times: each shift moves grid[i][j] to grid[i][j + 1], wraps the last elemen...