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.
Maximum Number of Removable Characters (可移除字符的最大数目)
You are given strings s and p, and an array removable of indices into s. You may remove the characters at the first k indices of r...
Most Beautiful Item for Each Query (每一个查询的最大美丽值)
You are given a 2D array items where items[i] = [price_i, beauty_i], and an array of queries. For each query, return the maximum b...
Random Pick with Weight (按权重随机选择)
You are given a 0-indexed array of positive integers w where w[i] describes the weight of index i. Implement pickIndex() which ret...
Search Suggestions System (搜索推荐系统)
You are given an array of strings products and a string searchWord. After typing each character of searchWord, return up to three ...
Count the Number of Fair Pairs (统计公平数对的数目)
Given a 0-indexed integer array nums and two integers lower and upper, return the number of fair pairs: pairs (i, j) with i < j...
Binary Searchable Numbers in an Unsorted Array (未排序数组中的可二分查找数)
A binary searchable number in an array is one that would be found by the standard binary search procedure regardless of the search...
Leftmost Column with at Least a One (至少有一个 1 的最左端列)
This is an interactive problem. A binary matrix has each row sorted in non-decreasing order. BinaryMatrix.get(row, col) returns a ...
Cutting Ribbons (割绳子)
You are given an array ribbons where ribbons[i] is the length of the i-th ribbon, and an integer k. You may cut each ribbon into p...
Split Array Largest Sum (分割数组的最大值)
Given an array nums of non-negative integers and an integer k, split the array into k non-empty contiguous subarrays so that the l...
Find K-th Smallest Pair Distance (找出第 K 小的数对距离)
Given an integer array nums and an integer k, return the k-th smallest distance among all pairs. The distance between a pair is th...
Median of Two Sorted Arrays (寻找两个正序数组的中位数)
Given two sorted arrays nums1 and nums2, return the median of the combined array. The overall run time must be O(log(m + n)). Cons...
Find in Mountain Array (山脉数组中查找目标值)
This is an interactive problem. A MountainArray is strictly increasing then strictly decreasing. Given a target, return the minimu...
Kth Smallest Product of Two Sorted Arrays (两个有序数组的第 K 小乘积)
Given two sorted arrays nums1 and nums2 and an integer k, return the k-th smallest product among all nums1[i] * nums2[j]. Constrai...
Minimize Max Distance to Gas Station (最小化加油次数)
You are given a sorted array stations of gas station positions and an integer k. You may add k new stations anywhere. Return the s...
Reverse Linked List (反转链表)
Given the head of a singly linked list, reverse the list and return the new head. Constraints: the number of nodes is in [0, 5000]...
Merge Two Sorted Lists (合并两个有序链表)
You are given the heads of two sorted linked lists list1 and list2. Merge them into one sorted list by splicing together the exist...
Linked List Cycle (环形链表)
Given the head of a linked list, determine whether the list contains a cycle. Return true if some node can be reached again by fol...
Palindrome Linked List (回文链表)
Given the head of a singly linked list, return true if it is a palindrome. Constraints: the number of nodes is in [1, 10^5], 0 <...
Remove Linked List Elements (移除链表元素)
Given the head of a linked list and an integer val, remove all nodes whose value equals val and return the new head. Constraints: ...
Remove Duplicates from Sorted List (删除排序链表中的重复元素)
Given the head of a sorted linked list, delete all duplicates so each value appears once, and return the head. Constraints: the nu...
Middle of the Linked List (链表的中间结点)
Given the head of a singly linked list, return the middle node. If there are two middle nodes, return the second one. Constraints:...
Intersection of Two Linked Lists (相交链表)
Given the heads of two singly linked lists headA and headB, return the node at which they intersect, or null if they do not. The l...
Delete N Nodes After M Nodes of a Linked List (删除链表 M 个节点之后的 N 个节点)
Given the head of a linked list and two integers m and n, traverse the list and delete n nodes after keeping m nodes, repeating un...
Insert into a Sorted Circular Linked List (循环有序列表的插入)
Given the head of a sorted circular linked list and an integer insertVal, insert the value so the list remains sorted, and return ...