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.
Number of Flowers in Full Bloom (花期内花的数目)
You are given flowers where flowers[i] = [start, end] is the blooming interval of the i-th flower, and people where people[i] is a...
Constrained Subsequence Sum (带限制的子序列和)
Given an integer array nums and an integer k, return the maximum sum of a non-empty subsequence such that for every two consecutiv...
Find Building Where Alice and Bob Can Meet (找到 Alice 和 Bob 可以相遇的建筑)
You are given an array heights and queries where queries[i] = [a, b]. For each query, find the leftmost index c such that max(a, b...
Island Perimeter (岛屿的周长)
You are given a row x col grid of 1s (land) and 0s (water) representing a single island with no lakes. Return the island's perimet...
Verifying an Alien Dictionary (验证外星语词典)
In an alien language the alphabet has a different order given by order. Given a sequence of words, return true if they are sorted ...
Find the Town Judge (找到小镇的法官)
In a town of n people labelled 1..n, trust[i] = [a, b] means person a trusts person b. The judge trusts nobody, and everybody else...
Flood Fill (图像渲染)
You are given an image as an m x n integer grid, a starting pixel (sr, sc) and a new color. Perform a flood fill: recolor the star...
Count Servers that Communicate (统计参与通信的服务器)
You are given an m x n grid where 1 is a server. Two servers communicate if they are in the same row or column. Return the number ...
Find Champion II (找到冠军 II)
There are n teams numbered 0..n-1 in a tournament. edges[i] = [u, v] means team u is stronger than team v. A team is the champion ...
Number of Islands (岛屿数量)
Given an m x n 2D binary grid where '1' is land and '0' is water, return the number of islands. An island is surrounded by water a...
Max Area of Island (岛屿的最大面积)
Given an m x n binary matrix grid, return the maximum area of an island (1 is land, 0 is water). Return 0 if there is no island. C...
Maximum Number of Fish in a Grid (网格图中鱼的最大数目)
You are given an m x n grid where 0 is water and a positive value is the number of fish in that water cell. A fisherman can start ...
Clone Graph (克隆图)
Given a reference to a node in a connected undirected graph, return a deep copy of the graph. Each node has a value and a list of ...
Walls and Gates (墙与门)
You are given an m x n grid of rooms where -1 is a wall, 0 is a gate, and 2147483647 is an empty room. Fill each empty room with t...
Rotting Oranges (腐烂的橘子)
You are given an m x n grid where 0 is empty, 1 is a fresh orange and 2 is a rotten orange. Each minute, fresh oranges adjacent to...
Count Sub Islands (统计子岛屿)
You are given two m x n binary grids grid1 and grid2. An island in grid2 is a sub-island if all of its cells are also land in grid...
Pacific Atlantic Water Flow (太平洋大西洋水流问题)
There is an m x n rectangular island. The Pacific Ocean touches the left and top edges, the Atlantic the right and bottom edges. G...
Surrounded Regions (被围绕的区域)
Given an m x n board of 'X' and 'O', capture all regions of 'O' that are completely surrounded by 'X' by turning them into 'X'. 'O...
Reorder Routes to Make All Paths Lead to the City Zero (重新规划路线)
There are n cities numbered 0..n-1 and n - 1 directed roads forming a tree. connections[i] = [a, b] means the road goes from a to ...
Snakes and Ladders (蛇梯棋)
You are given an n x n board representing a Snakes and Ladders board, numbered boustrophedon from the bottom-left. From square s y...
Open the Lock (打开转盘锁)
A lock has four circular dials with digits 0-9. Starting from "0000", each move turns one dial one step in either direction. Given...
Find Eventual Safe States (找到最终的安全状态)
There is a directed graph of n nodes where graph[i] lists the nodes reachable from i. A node is safe if every possible path starti...
Course Schedule (课程表)
There are numCourses courses labelled 0..numCourses-1. Given prerequisites where prerequisites[i] = [a, b] means b must be taken b...
Course Schedule II (课程表 II)
There are numCourses courses and prerequisites[i] = [a, b] means b before a. Return a valid order to finish all courses, or an emp...