Number Theory DSA Problems

73 number theory problems for coding interviews and campus placements, with hints and company tags. Below are all 73: 10 easy, 32 medium and 31 hard. Practise them free on InternHack and track what you have solved.

Number Theory problems, easiest first

  1. Add Digits (Easy)
  2. Check If Digits Are Equal in String After Operations I (Easy)
  3. Find Greatest Common Divisor of Array (Easy)
  4. GCD of Odd and Even Sums (Easy)
  5. Maximum Subarray With Equal Products (Easy)
  6. Number of Common Factors (Easy)
  7. Prime In Diagonal (Easy)
  8. Smallest Even Multiple (Easy)
  9. Three Divisors (Easy)
  10. X of a Kind in a Deck of Cards (Easy)
  11. Balanced K-Factor Decomposition (Medium)
  12. Closest Prime Numbers in Range (Medium)
  13. Count Beautiful Substrings I (Medium)
  14. Count Prime-Gap Balanced Subarrays (Medium)
  15. Count Primes (Medium)
  16. Digit Operations to Make Two Integers Equal (Medium)
  17. Distinct Prime Factors of Product of Array (Medium)
  18. Find the Maximum Factor Score of Array (Medium)
  19. Find Triangular Sum of an Array (Medium)
  20. Insert Greatest Common Divisors in Linked List (Medium)
  21. Largest Prime from Consecutive Prime Sum (Medium)
  22. Make K-Subarray Sums Equal (Medium)
  23. Maximum Prime Difference (Medium)
  24. Minimize Length of Array Using Operations (Medium)
  25. Minimize the Maximum of Two Arrays (Medium)
  26. Minimum Division Operations to Make Array Non Decreasing (Medium)
  27. Minimum Jumps to Reach End via Prime Teleportation (Medium)
  28. Minimum Lines to Represent a Line Chart (Medium)
  29. Minimum Number of Operations to Make All Array Elements Equal to 1 (Medium)
  30. Minimum Number of Primes to Sum to Target (Medium)
  31. Mirror Reflection (Medium)
  32. Most Expensive Item That Can Not Be Bought (Medium)
  33. Most Frequent Prime (Medium)
  34. Number of Pairs of Interchangeable Rectangles (Medium)
  35. Number of Self-Divisible Permutations (Medium)
  36. Number of Subarrays With LCM Equal to K (Medium)
  37. Prime Palindrome (Medium)
  38. Prime Subtraction Operation (Medium)
  39. Simplified Fractions (Medium)
  40. Sum of Largest Prime Substrings (Medium)
  41. The kth Factor of n (Medium)
  42. Ugly Number III (Medium)
  43. Abbreviating the Product of a Range (Hard)
  44. Apply Operations to Maximize Score (Hard)
  45. Check If Digits Are Equal in String After Operations II (Hard)
  46. Check If It Is a Good Array (Hard)
  47. Check if Point Is Reachable (Hard)
  48. Count Array Pairs Divisible by K (Hard)
  49. Count Beautiful Substrings II (Hard)
  50. Count the Number of Ideal Arrays (Hard)
  51. Count Valid Paths in a Tree (Hard)
  52. Count Ways to Make Array With Product (Hard)
  53. Find the Largest Palindrome Divisible by K (Hard)
  54. Find the Number of Subsequences With Equal GCD (Hard)
  55. GCD Sort of an Array (Hard)
  56. Graph Connectivity With Threshold (Hard)
  57. Largest Component Size by Common Factor (Hard)
  58. Maximize Number of Nice Divisors (Hard)
  59. Maximize Score After N Operations (Hard)
  60. Maximize Subarray GCD Score (Hard)
  61. Maximum Element-Sum of a Complete Subset of Indices (Hard)
  62. Maximum GCD-Sum of a Subarray (Hard)
  63. Minimum Deletions to Make Array Divisible (Hard)
  64. Minimum Stability Factor of Array (Hard)
  65. Number of Different Subsequences GCDs (Hard)
  66. Replace Non-Coprime Numbers in Array (Hard)
  67. Smallest Divisible Digit Product II (Hard)
  68. Sorted GCD Pair Queries (Hard)
  69. Split the Array to Make Coprime Products (Hard)
  70. Sum of Beautiful Subsequences (Hard)
  71. Sum of Perfect Square Ancestors (Hard)
  72. The Number of Good Subsets (Hard)
  73. Tree of Coprimes (Hard)

Companies that ask number theory problems

Before your interview

Most resumes are filtered by software before a recruiter reads them. Check your resume ATS score free, no signup needed.

Other DSA topics