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.
Bitwise XOR of All Pairings (所有数对的异或值总和)
You are given two 0-indexed arrays nums1 and nums2 of non-negative integers. Consider every pairing (i, j) with 0 <= i < n a...
Largest Combination With Bitwise AND Greater Than Zero (按位与大于零的最大组合)
Given an integer array candidates, choose a combination (subset) whose bitwise AND is greater than zero, and maximise its size. Re...
XOR Queries of a Subarray (子数组异或查询)
Given an array arr and an array of queries where queries[i] = [left, right], return an array holding the XOR of arr[left..right] f...
Maximum XOR for Each Query (每个查询的最大异或值)
You are given a sorted array nums of n non-negative integers and an integer maximumBit. Perform n queries: in the i-th query, take...
Neighboring Bitwise XOR (相邻值的按位异或)
A binary array original of length n derives an array derived where derived[i] = original[i] XOR original[(i + 1) % n]. Given deriv...
Shortest Subarray With OR at Least K II (或值至少为 K 的最短子数组 II)
Given an array nums of non-negative integers and an integer k, return the length of the shortest non-empty subarray whose bitwise ...
Bitwise AND of Numbers Range (数字范围按位与)
Given two integers left and right representing the inclusive range [left, right], return the bitwise AND of every number in that r...
Find Kth Bit in Nth Binary String (找出第 N 个二进制字符串中的第 K 位)
The binary string S_1 is 0, and for n > 1 the string S_n is S_{n-1} followed by 1 followed by the reverse of the bit-inverted S...
Count Triplets That Can Form Two Arrays of Equal XOR (形成两个异或相等数组的三元组数目)
Given an array arr, count the triplets (i, j, k) with i < j <= k such that the XOR of arr[i..j-1] equals the XOR of arr[j..k...
Minimum Array End (数组最后一个元素的最小值)
Given two integers n and x, build an array nums of n positive integers such that nums is strictly increasing and the bitwise AND o...
Find if Array Can Be Sorted (判断一个数组是否可以变为有序)
Given an array nums of positive integers, you may swap two adjacent elements only if they have the same number of set bits. Return...
Longest Subarray With Maximum Bitwise AND (按位与最大的最长子数组)
Given an array nums of integers, return the length of the longest subarray whose bitwise AND equals the maximum AND achievable by ...
Longest Nice Subarray (最长优雅子数组)
A subarray is called nice if the bitwise AND of every pair of elements at different positions in it is 0. Return the length of the...
Find the Longest Substring Containing Vowels in Even Counts (每个元音包含偶数次的最长子字符串)
Given a string s, return the length of the longest substring in which each of the vowels a, e, i, o, u occurs an even number of ti...
Minimize XOR (最小异或)
Given two positive integers num1 and num2, find a positive integer x that has exactly the same number of set bits as num2 and mini...
IP to CIDR (IP 到 CIDR)
Given a start IPv4 address ip and an integer n, return the smallest list of CIDR blocks that together cover every address from ip ...
Excel Sheet Column Title (Excel 表列名称)
Given an integer columnNumber, return its corresponding column title as it appears in Excel, where column 1 is A, column 26 is Z, ...
Greatest Common Divisor of Strings (字符串的最大公因子)
For two strings str1 and str2, return the largest string x such that x divides both, meaning both strings are formed by concatenat...
Insert Greatest Common Divisors in Linked List (在链表中插入最大公约数)
Given the head of a linked list whose nodes contain integers, insert a new node between every pair of adjacent nodes; the new node...
Count Odd Numbers in an Interval Range (在区间范围内统计奇数数目)
Given two non-negative integers low and high, return the number of odd integers in the inclusive range [low, high]. Constraints: 0...
Matrix Diagonal Sum (矩阵对角线元素的和)
Given a square matrix mat, return the sum of the elements on the primary diagonal (top-left to bottom-right) and the secondary dia...
Calculate Money in Leetcode Bank (计算力扣银行的钱)
Hercy saves money every day. On Monday of the first week he saves 1, and each following day he saves one more than the previous da...
Largest Odd Number in String (字符串中的最大奇数)
Given a string num representing a large integer, return the largest-valued odd integer that is a prefix of num, or an empty string...
Transpose Matrix (转置矩阵)
Given a 2D integer array matrix, return its transpose: the matrix whose element at row j, column i equals matrix[i][j]. Constraint...