面试场景
高频考察问题建模、边界条件与口头表达的清晰度。
常见误区
只背模板不解释为什么,容易在追问里失分。
练习策略
每轮练 3-5 题,固定复盘复杂度和可替代解法。
推荐练习顺序
计数质数
Count all prime numbers less than a given integer n using efficient array and math-based enumeration techniques.
各位相加
Add Digits involves repeatedly summing digits of a number until a single digit is obtained.
镜面反射
Given a square room with mirrors, find which receptor a laser ray will hit first based on two integers, p and q.
回文质数
The Prime Palindrome problem asks for the smallest prime palindrome greater than or equal to a given integer.
卡牌分组
Solve the problem of determining if a deck can be partitioned into groups with equal occurrences of card values.
按公因数计算最大组件大小
Find the largest connected component in an array where edges exist between numbers sharing a common factor greater than …
丑数 III
Find the nth positive integer divisible by a, b, or c using binary search over the answer space efficiently and accurate…
检查「好数组」
Determine if a given array of positive integers can generate 1 using integer multiples of any subset, leveraging number …
最简分数
Generate simplified fractions between 0 and 1 with denominators up to a given integer n.
n 的第 k 个因子
Find the kth factor of n by scanning divisors carefully or using factor pairs to skip unnecessary checks.
带阈值的图连通性
In 'Graph Connectivity With Threshold,' determine if cities are connected based on common divisors exceeding a threshold…
生成乘积数组的方案数
Determine the number of arrays of size n where the product equals k using prime factorization and combinatorial DP techn…
互质树
Determine the closest coprime ancestor for each node in a tree using efficient traversal and state tracking of node valu…
N 次操作后的最大分数和
Maximize the score after n operations by selecting pairs from the array and using their GCD with dynamic programming or …
好因子的最大数目
Solve Maximize Number of Nice Divisors by splitting primeFactors into mostly 3s and using fast modular exponentiation.
序列中不同最大公约数的数目
Given an array of positive integers, find the number of different subsequences' GCDs.
三除数
Determine if a given integer has exactly three positive divisors.
找出数组的最大公约数
Find the greatest common divisor of the smallest and largest numbers in an integer array.
好子集的数目
Find the number of good subsets in an integer array, where each subset's product is the product of distinct primes.
数组的最大公因数排序
The GCD Sort problem challenges you to sort an array using a specific gcd-based swap method.
可互换矩形的组数
Count all pairs of rectangles that share the exact width-to-height ratio using efficient array scanning and hash lookup.
统计可以被 K 整除的下标对数目
Count Array Pairs Divisible by K requires counting index pairs whose products are divisible by a given number k.
替换数组中的非互质数
Replace Non-Coprime Numbers in Array uses stack-based state management to iteratively merge adjacent non-coprime integer…
表示一个折线图的最少线段数
Determine the fewest lines needed to accurately connect stock price points in a line chart using array and math reasonin…
统计理想数组的数目
This problem involves counting the number of ideal arrays of a given length under certain conditions using state transit…
使数组可以被整除的最少删除次数
Find the minimum number of deletions to make the smallest element in nums divide all elements of numsDivide.
最小偶倍数
Find the smallest even multiple of a given integer using math and number theory concepts efficiently.
公因子的数目
The problem asks to find the number of common factors of two positive integers a and b.
最大公因数等于 K 的子数组数目
Count the number of subarrays with GCD equal to a given value k from a list of integers.
最小公倍数等于 K 的子数组数目
Find the number of subarrays in an array where the least common multiple (LCM) of the subarray equals a given integer k.
使用质因数之和替换后可以取到的最小值
Replace a number with the sum of its prime factors until it stabilizes, and return the smallest value.
最小化两个数组中的最大值
Minimize the Maximum of Two Arrays requires finding the smallest possible maximum number across two arrays, using binary…
数组乘积中的不同质因数数目
Find the number of distinct prime factors in the product of an array of integers.
范围内最接近的两个质数
Find the two closest prime numbers within a given range using efficient number theory techniques and gap comparisons.
判断一个点是否可以到达
Determine if a target point is reachable from (1,1) using math-based moves following number theory rules efficiently.
分割数组使乘积互质
Find the smallest index to split an array so that the products of two parts are coprime using array scanning and hash lo…
质数减法运算
Determine if it's possible to make the array strictly increasing using prime subtractions.
使子数组元素和相等
Solve Make K-Subarray Sums Equal by grouping circular indices with gcd cycles and minimizing each group to its median.
对角线上的质数
Find the largest prime number located on any diagonal of a square matrix using array iteration and prime checking techni…
使数组所有元素变成 1 的最少操作次数
Find the minimum number of operations to transform every element of a positive integer array into 1 using gcd operations…
最大公约数遍历
Determine if every index in an array can be reached from any other using traversals based on greatest common divisors.
美丽下标对的数目
Count all index pairs in an array where the first digit of one number and last digit of another are coprime efficiently.
和等于目标值的质数对
Find all prime number pairs that sum up to a given integer n using an efficient sieve-based array approach.
在链表中插入最大公约数
The problem involves inserting greatest common divisors between adjacent nodes in a linked list.
操作使得分最大
Maximize the score by applying operations on a subarray at most k times, utilizing stack-based state management.
完全子集的最大元素和
Given a 1-indexed array, select a subset where indices' product is a perfect square, then return the maximum sum.
统计树中的合法路径数目
Count Valid Paths in a Tree involves finding paths with exactly one prime number in a tree of n nodes.
统计美丽子字符串 I
Given a string and a value k, count the number of beautiful substrings where vowels * consonants % k == 0.
统计美丽子字符串 II
Count Beautiful Substrings II focuses on finding beautiful substrings with hash tables and number theory techniques.
通过操作使数组长度最小
Minimize the length of an integer array through a series of operations, using a greedy approach with modular arithmetic.
出现频率最高的质数
Find the most frequent prime over 10 from numbers generated by scanning a 2D matrix in all straight directions efficient…
质数的最大距离
Calculate the largest index gap between prime numbers in an array using array traversal and number theory insights effic…
单面值组合的第 K 小金额
Find the kth smallest amount using only one coin denomination at a time, applying binary search efficiently over possibl…
统计不是特殊数字的数字数量
Count the numbers between two integers that are not special, where special numbers are squares of primes.
找出最大的 N 位 K 回文数
Compute the largest n-digit integer divisible by k that forms a palindrome using state transition dynamic programming te…
查询排序后的最大公约数
Solve the Sorted GCD Pair Queries problem by efficiently counting and locating GCDs of all array pairs using hash mappin…
使数组非递减的最少除法操作次数
Determine the minimum number of division operations to make an array non-decreasing using a greedy and invariant-based s…
数组的最大因子得分
Calculate the maximum factor score of an integer array by optionally removing one element using LCM and GCD computations…
最大公约数相等的子序列数量
Count all pairs of non-empty subsequences in an integer array whose elements share the same greatest common divisor effi…
最小可整除数位乘积 II
Find the smallest zero-free number at least as large as num whose digits multiply to a product divisible by t using care…
使两个整数相等的数位操作
Transform n into m using allowed digit operations without creating primes, applying math and graph strategies efficientl…
统计最小公倍数图中的连通块数目
Determine the number of connected components in an LCM-based graph using array scanning and hash-based connectivity chec…
最长乘积等价子数组
This problem involves finding the longest subarray where the product equals the LCM multiplied by the GCD, leveraging a …
使数组包含目标值倍数的最少增量
This problem involves incrementing elements of an array to make sure each target element has at least one multiple in th…
判断操作后字符串中的数字是否相等 I
Simulate repeated adjacent digit sums modulo 10 until two digits remain, then check whether those final digits match.
判断操作后字符串中的数字是否相等 II
Determine if repeated digit-sum operations on a numeric string reduce it to two equal digits using math and string techn…
最大质数子字符串之和
Compute the sum of the three largest unique primes from all substrings using hash table plus math efficiently.
分割数组后不同质数的最大数目
Compute the maximum number of distinct prime numbers after sequentially updating array elements with efficient preproces…
最大子数组 GCD 分数
Maximize Subarray GCD Score focuses on maximizing a subarray's score by using at most k doubling operations on an array …
计数质数间隔平衡子数组
Count the number of prime-gap balanced subarrays in an integer array using sliding window techniques and running state u…
检查元素频次是否为质数
Check if any element in the array has a prime frequency count, leveraging array scanning and hash table lookup.
数组的最小稳定性因子
The problem requires finding the minimum stability factor of an array by utilizing binary search and math-based optimiza…
根据质数下标分割数组
Split Array by Prime Indices challenges you to separate elements at prime positions and minimize the absolute sum differ…