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.
Minimum Height Trees (最小高度树)
A tree is an undirected graph with no cycles. Given a tree of n nodes labelled 0..n-1 and edges, return all labels that can be roo...
Path with Maximum Gold (黄金矿工)
In a gold mine grid, each cell holds a non-negative amount of gold; 0 means an obstacle. Starting anywhere, you may move in the fo...
Most Profitable Path in a Tree (树上最大得分和路径)
There is a tree of n nodes rooted at 0. Alice starts at 0 and Bob at bob; both move one edge per second toward node 0, and Bob can...
Find the Celebrity (搜寻名人)
This is an interactive problem. In a party of n people, a celebrity is known by everyone else but knows nobody. Given knows(a, b) ...
Kill Process (杀掉进程)
You are given pid (process ids), ppid (parent ids, 0 means no parent) and kill (the process to kill). When a process is killed, al...
All Paths from Source Lead to Destination (从始点到终点的所有路径)
You are given n nodes, a list of directed edges, and source and destination. Return true if every path from source eventually reac...
Web Crawler (网络爬虫)
This is an interactive problem. Given a startUrl and an HtmlParser with getUrls(url) returning the links on a page, return all URL...
Number of Distinct Islands (不同岛屿的数量)
You are given an m x n binary matrix grid. An island is a group of 1s connected 4-directionally. Two islands are considered the sa...
Parallel Courses (并行课程)
You are given n courses and relations where relations[i] = [a, b] means course a must be taken before b. In one semester you may t...
The Maze (迷宫)
A ball rolls in a maze of 0 (empty) and 1 (wall) cells until it hits a wall. Given start and destination, return whether the ball ...
The Maze II (迷宫 II)
A ball rolls in a maze until it hits a wall. Given start and destination, return the shortest distance (number of empty cells pass...
Minimum Knight Moves (进击的骑士)
A knight moves on an infinite chessboard. Given x and y, return the minimum number of moves to reach (x, y) from (0, 0). Constrain...
Number of Islands II (岛屿数量 II)
You are given m, n and a list of positions where land is added one cell at a time. After each addition, return the number of islan...
The Maze III (迷宫 III)
A ball rolls in a maze with 0 (empty), 1 (wall) and one hole. The ball falls into the hole if it passes over it. Given ball and ho...
Shortest Distance from All Buildings (离建筑物最近的距离)
You are given an m x n grid where 0 is empty, 1 is a building and 2 is an obstacle. You want to build a house on an empty cell rea...
Nested List Weight Sum (嵌套列表加权和)
This is an interactive problem. You are given a nested list of integers where each element is an integer or a list. Return the sum...
Maximum Number of Points From Grid Queries (矩阵查询可获得的最大分数)
You are given an m x n grid and queries. For each query q, start at the top-left and repeatedly move to an adjacent cell with a va...
Maximum Number of K-Divisible Components (可以被 K 整除连通块的最大数目)
You are given a tree of n nodes, edges, values for each node, and an integer k. Remove some edges so that every resulting componen...
Sliding Puzzle (滑动谜题)
On a 2x3 board there are tiles 1-5 and a blank (0). A move slides a tile into the adjacent blank. Given a board configuration, ret...
Largest Color Value in a Directed Graph (有向图中最大颜色值)
You are given a directed graph of n coloured nodes (colors[i] is a lowercase letter) and edges. A valid path follows the edge dire...
Minimum Number of Days to Eat N Oranges (吃掉 N 个橘子的最少天数)
There are n oranges. Each day you may: eat one orange, eat n/2 oranges if n is divisible by 2, or eat 2n/3 oranges if n is divisib...
Find All People With Secret (找出知晓秘密的所有专家)
You are given n people, meetings where meetings[i] = [x, y, time] means persons x and y meet at that time, and firstPerson. Person...
Word Ladder (单词接龙)
A transformation sequence from beginWord to endWord changes one letter at a time, and every intermediate word must be in wordList....
Parallel Courses III (并行课程 III)
You are given n courses, relations[i] = [a, b] meaning a must be taken before b, and time[i] for the duration of course i+1. Cours...