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 Distinct Islands II (不同岛屿的数量 II)
You are given an m x n binary matrix grid. Two islands are considered the same if one can be translated, rotated by 90/180/270 deg...
Sentence Similarity II (句子相似性 II)
You are given two sentences as arrays of words and a list of similarPairs. Determine whether the sentences are similar, where simi...
Path With Minimum Effort (最小体力消耗路径)
You are given an m x n grid of heights. A route's effort is the maximum absolute difference in heights between consecutive cells. ...
Network Delay Time (网络延迟时间)
You are given times where times[i] = [u, v, w] is a directed edge taking w time, and n nodes labelled 1..n. Starting from node k, ...
Reconstruct Itinerary (重新安排行程)
You are given a list of airline tickets where tickets[i] = [from, to]. Reconstruct the itinerary in order, starting from "JFK", us...
Min Cost to Connect All Points (连接所有点的最小费用)
You are given an array of points on a 2D plane. Return the minimum cost to connect all points, where the cost between two points i...
Path with Maximum Probability (概率最大的路径)
You are given an undirected weighted graph with n nodes, edges and succProb (the success probability of each edge), plus start_nod...
Find the Safest Path in a Grid (找出最安全路径)
You are given an n x n grid where 1 is a thief and 0 is empty. The safeness factor of a path is the minimum Manhattan distance fro...
Swim in Rising Water (水位上升的泳池中游泳)
You are given an n x n grid where grid[i][j] is the elevation. Rain starts falling at time t, and you can swim to adjacent cells o...
Alien Dictionary (火星词典)
You are given a list of words sorted lexicographically in an alien language. Derive the order of the letters. If the order is inva...
Trapping Rain Water II (接雨水 II)
Given an m x n matrix of heights, compute how much water it can trap after raining. Constraints: 1 <= m, n <= 200, 0 <= h...
Minimum Obstacle Removal to Reach Corner (到达角落需要移除障碍物的最小数目)
You are given an m x n grid where 0 is empty and 1 is an obstacle. You may move in the four cardinal directions; moving into an ob...
Minimum Cost to Make at Least One Valid Path in a Grid (使网格图至少有一条有效路径的最小代价)
You are given an m x n grid where each cell holds an arrow direction (1 = right, 2 = left, 3 = down, 4 = up). You may modify any c...
Minimum Time to Visit a Cell In a Grid (在网格图中访问一个格子的最少时间)
You are given an m x n grid where grid[i][j] is the earliest time you may enter cell (i, j). You start at (0, 0) at time 0 and eac...
Cheapest Flights Within K Stops (K 站中转内最便宜的航班)
You are given n cities, flights where flights[i] = [from, to, price], and integers src, dst and k. Return the cheapest price from ...
Find the City With the Smallest Number of Neighbors at a Threshold Distance (阈值距离内邻居最少的城市)
There are n cities with edges[i] = [from, to, weight]. Given distanceThreshold, return the city with the smallest number of reacha...
Minimum Cost to Convert String I (转换字符串的最小成本 I)
You are given source, target, and parallel arrays original, changed, cost describing conversions between lowercase letters. Return...
Number of Ways to Arrive at Destination (到达目的地的方案数)
You are given n intersections and roads[i] = [u, v, time] as undirected roads. Return the number of ways to travel from 0 to n-1 i...
Sequence Reconstruction (序列重建)
You are given an integer array nums of length n and a list of sequences, each a subsequence of nums. Return true if nums is the sh...
Making A Large Island (最大人工岛)
You are given an n x n binary matrix grid. You may change at most one 0 to 1. Return the size of the largest island possible. Cons...
Minimum Cost Walk in Weighted Graph (带权图里旅游的最小代价)
You are given n nodes, edges[i] = [u, v, w] as undirected weighted edges, and query[i] = [s, t]. The cost of a walk from s to t is...
Number of Good Paths (好路径的数目)
You are given a tree of n nodes with vals[i] and edges. A good path is a simple path whose two endpoints have the same value and e...
Maximum Employees to Be Invited to a Meeting (参加会议的最多员工数)
There are n employees, each with one favourite colleague given in favorite[i]. Seating is circular and each person must sit next t...
Remove Max Number of Edges to Keep Graph Fully Traversable (保证图可完全遍历)
Alice and Bob share an undirected graph of n nodes. edges[i] = [type, u, v]: type 1 is Alice-only, type 2 is Bob-only, type 3 is b...