Skip to content
Use code for 50% offSee plans

Number Theory Problems

73 Number Theory LeetCode problems · Solve with AI-powered hints & step-by-step explanations.

Learn the coding interview patterns behind these problems.

Start with these

All Number Theory problems

204 Count Primes Medium258 Add Digits Easy858 Mirror Reflection Medium866 Prime Palindrome Medium914 X of a Kind in a Deck of Cards Easy952 Largest Component Size by Common Factor Hard1201 Ugly Number III Medium1250 Check If It Is a Good Array Hard1447 Simplified Fractions Medium1492 The kth Factor of n Medium1627 Graph Connectivity With Threshold Hard1735 Count Ways to Make Array With Product Hard1766 Tree of Coprimes Hard1799 Maximize Score After N Operations Hard1808 Maximize Number of Nice Divisors Hard1819 Number of Different Subsequences GCDs Hard1952 Three Divisors Easy1979 Find Greatest Common Divisor of Array Easy1994 The Number of Good Subsets Hard1998 GCD Sort of an Array Hard2001 Number of Pairs of Interchangeable Rectangles Medium2183 Count Array Pairs Divisible by K Hard2197 Replace Non-Coprime Numbers in Array Hard2280 Minimum Lines to Represent a Line Chart Medium2338 Count the Number of Ideal Arrays Hard2344 Minimum Deletions to Make Array Divisible Hard2413 Smallest Even Multiple Easy2427 Number of Common Factors Easy2447 Number of Subarrays With GCD Equal to K Medium2470 Number of Subarrays With LCM Equal to K Medium2507 Smallest Value After Replacing With Sum of Prime Factors Medium2513 Minimize the Maximum of Two Arrays Medium2521 Distinct Prime Factors of Product of Array Medium2523 Closest Prime Numbers in Range Medium2543 Check if Point Is Reachable Hard2584 Split the Array to Make Coprime Products Hard2601 Prime Subtraction Operation Medium2607 Make K-Subarray Sums Equal Medium2614 Prime In Diagonal Easy2654 Minimum Number of Operations to Make All Array Elements Equal to 1 Medium2709 Greatest Common Divisor Traversal Hard2748 Number of Beautiful Pairs Easy2761 Prime Pairs With Target Sum Medium2807 Insert Greatest Common Divisors in Linked List Medium2818 Apply Operations to Maximize Score Hard2862 Maximum Element-Sum of a Complete Subset of Indices Hard2867 Count Valid Paths in a Tree Hard2947 Count Beautiful Substrings I Medium2949 Count Beautiful Substrings II Hard3012 Minimize Length of Array Using Operations Medium3044 Most Frequent Prime Medium3115 Maximum Prime Difference Medium3116 Kth Smallest Amount With Single Denomination Combination Hard3233 Find the Count of Numbers Which Are Not Special Medium3260 Find the Largest Palindrome Divisible by K Hard3312 Sorted GCD Pair Queries Hard3326 Minimum Division Operations to Make Array Non Decreasing Medium3334 Find the Maximum Factor Score of Array Medium3336 Find the Number of Subsequences With Equal GCD Hard3348 Smallest Divisible Digit Product II Hard3377 Digit Operations to Make Two Integers Equal Medium3378 Count Connected Components in LCM Graph Hard3411 Maximum Subarray With Equal Products Easy3444 Minimum Increments for Target Multiples in an Array Hard3461 Check If Digits Are Equal in String After Operations I Easy3463 Check If Digits Are Equal in String After Operations II Hard3556 Sum of Largest Prime Substrings Medium3569 Maximize Count of Distinct Primes After Split Hard3574 Maximize Subarray GCD Score Hard3589 Count Prime-Gap Balanced Subarrays Medium3591 Check if Any Element Has Prime Frequency Easy3605 Minimum Stability Factor of Array Hard3618 Split Array by Prime Indices Medium