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.
Sentence Screen Fitting (屏幕可显示句子的数量)
Given sentence (a list of words) and a screen with rows rows and cols columns, count how many times the sentence can be repeated b...
Stone Game III (石子游戏 III)
Alice and Bob play with a row of stones stoneValue. Starting with Alice, each player takes 1, 2, or 3 stones from the front and ad...
Concatenated Words (连接词)
Given an array of distinct strings words, return all words that can be formed by concatenating at least two shorter words from the...
Maximize Score After N Operations (N 次操作后的最大分数和)
Given nums of length 2 * n, perform n operations. In operation i (1-indexed) you pick two unused numbers a and b and gain i * gcd(...
Find the Longest Valid Obstacle Course at Each Position (找出到每个位置为止最长的有效障碍赛跑路线)
For each index i in obstacles, find the length of the longest non-decreasing subsequence that ends at i, and return the array of t...
Minimum Number of Removals to Make Mountain Array (得到山形数组的最少删除次数)
Given nums, return the minimum number of elements to remove so that the remaining array is a mountain array: strictly increasing u...
Count All Valid Pickup and Delivery Options (有效的快递序列数目)
Given n orders, each with a pickup P_i and a delivery D_i, count the number of valid sequences of all 2n events in which P_i alway...
Number of Ways to Divide a Long Corridor (分隔长廊的方案数)
Given a corridor string corridor made of S (seat) and P (plant), place dividers on plants to split the corridor into sections that...
Maximum Sum of 3 Non-Overlapping Subarrays (三个无重叠子数组的最大和)
Given an integer array nums and an integer k, find three non-overlapping subarrays of length k with the maximum total sum and retu...
Maximum Profit in Job Scheduling (规划兼职工作)
Given startTime, endTime, and profit for n jobs, choose a subset of non-overlapping jobs (a job ending at time t does not conflict...
Student Attendance Record II (学生出勤记录 II)
Count the number of attendance records of length n (each day is A absent, L late, or P present) that contain at most one A and no ...
Optimal Account Balancing (最优账单平衡)
Given transactions, where transactions[i] = [from, to, amount] means from paid to that amount, return the minimum number of transa...
Valid Palindrome III (验证回文串 III)
Given a string s and an integer k, return true if s can be turned into a palindrome by deleting at most k characters. Constraints:...
Encode String with Shortest Length (编码最短长度的字符串)
Given a string s, return its shortest encoded form, where a substring that repeats k times may be written as k[encoded]. If the en...
Coin Path (金币路径)
Given an integer array coins, where 0 marks a position you may not land on, and an integer maxJump, find a path from index 0 to in...
Unique Paths (不同路径)
A robot starts at the top-left of an m x n grid and may move only right or down. Return the number of distinct paths to the bottom...
Unique Paths II (不同路径 II)
A robot moves right or down from the top-left to the bottom-right of an m x n grid that contains obstacles marked 1. Return the nu...
Minimum Path Sum (最小路径和)
Given an m x n grid of non-negative integers, find a path from the top-left to the bottom-right (moving right or down) that minimi...
Maximum Number of Points with Cost (扣分后的最大得分)
Given an m x n matrix points, choose exactly one cell in each row. The score is the sum of the chosen values minus the total penal...
Longest Common Subsequence (最长公共子序列)
Given strings text1 and text2, return the length of their longest common subsequence, or 0 if none exists. A subsequence preserves...
Longest Palindromic Subsequence (最长回文子序列)
Given a string s, return the length of its longest palindromic subsequence. Constraints: 1 <= s.length <= 1000, and s consis...
Length of Longest Fibonacci Subsequence (最长的斐波那契子序列的长度)
Given a strictly increasing array arr of positive integers, return the length of the longest Fibonacci-like subsequence, in which ...
Last Stone Weight II (最后一块石头的重量 II)
Given stone weights stones, repeatedly smash two stones together: if they are equal both vanish, otherwise the larger becomes thei...
Best Time to Buy and Sell Stock with Cooldown (最佳买卖股票时机含冷冻期)
Given prices, find the maximum profit from any number of buy/sell transactions, with the restriction that after selling you must w...