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.
Roman to Integer (罗马数字转整数)
Given a valid Roman numeral string s, convert it to an integer. Roman numerals use the symbols I, V, X, L, C, D, M and are written...
Integer to Roman (整数转罗马数字)
Given an integer num, convert it to a Roman numeral. Roman numerals use the symbols I, V, X, L, C, D, M plus the six subtractive p...
Pow(x, n) (Pow(x, n)
Implement pow(x, n), computing x raised to the integer power n, without using any built-in power function. Constraints: -100.0 <...
Find the Punishment Number of an Integer (求一个整数的惩罚数)
An integer i is called punishable if the decimal representation of i^2 can be partitioned into contiguous substrings whose integer...
Check if Number is a Sum of Powers of Three (判断一个数字是否可以表示成三的幂的和)
Given an integer n, return true if it can be written as the sum of distinct powers of three, otherwise false. Constraints: 1 <=...
Multiply Strings (字符串相乘)
Given two non-negative integers num1 and num2 represented as strings, return their product as a string. You must not use any built...
Detect Squares (检测正方形)
Design a class that stores points on the X-Y plane and answers, for a query point, how many axis-aligned squares can be formed usi...
Robot Bounded In Circle (困于环中的机器人)
A robot starts at (0, 0) facing north on an infinite plane and executes a list of instructions repeatedly forever: G moves forward...
Walking Robot Simulation (模拟行走机器人)
A robot starts at (0, 0) facing north on an infinite plane containing obstacles at the given coordinates. It executes commands in ...
Zigzag Conversion (Z 字形变换)
Given a string s and an integer numRows, write s in a zigzag pattern across numRows rows (moving down then diagonally up), then re...
Rotating the Box (旋转盒子)
Given an m x n box represented by a grid of characters, where # is a stone, * is a fixed obstacle and . is empty, rotate the box 9...
Sum of Square Numbers (平方数之和)
Given a non-negative integer c, decide whether there exist integers a and b such that a^2 + b^2 = c. Constraints: 0 <= c <= ...
Find Missing Observations (找出缺失的观测数据)
Given an array rolls of m dice observations (each in 1..6) plus integers mean and n, the n + m total observations average exactly ...
Minimum Time Difference (最小时间差)
Given a list timePoints of clock times formatted HH:MM on a 24-hour clock, return the smallest difference in minutes between any t...
Minimum Operations to Make a Uni-Value Grid (获取单值网格的最小操作数)
Given an m x n integer matrix grid and an integer x, one operation adds or subtracts x from any single element. Return the minimum...
Largest Submatrix With Rearrangements (重新排列后的最大子矩阵)
Given an m x n binary matrix, you may rearrange the elements of each column in any order. Return the area of the largest all-ones ...
Widest Vertical Area Between Two Points Containing No Points (两点之间不包含任何点的最宽垂直区域)
Given n points points[i] = [xi, yi], a vertical area is the region between two vertical lines containing no points. Return the wid...
Tuple with Same Product (同积元组)
Given an array nums of distinct positive integers, count the tuples (a, b, c, d) with a * b = c * d where a, b, c, d are four dist...
Lexicographical Numbers (字典序排数)
Given an integer n, return all integers from 1 to n sorted in lexicographical order. The solution should run in O(n) time and use ...
Find the Winner of the Circular Game (找出游戏的获胜者)
n friends numbered 1..n stand in a circle. Counting starts at friend 1; every k-th friend is eliminated and counting resumes from ...
Count Total Number of Colored Cells (统计染色格子数)
Starting from a single blue cell at minute 1, at every subsequent minute all uncolored cells sharing an edge with a blue cell are ...
Prime Subtraction Operation (质数减法运算)
Given an array nums, you may perform any number of operations: pick an unused index i and a prime p, then replace nums[i] with num...
Closest Prime Numbers in Range (范围内最接近的两个质数)
Given two integers left and right, find two primes p1 < p2 in [left, right] with the smallest difference. Return [p1, p2], or [...
Count Primes (计数质数)
Given an integer n, return the number of prime numbers strictly less than n. Constraints: 0 <= n <= 5 * 10^6.