Coding & Algorithms (DSA)

Math & Number Theory

6 practice questions. Free questions open a full answer guide; the rest unlock with Pro.

  • How would you check whether a single number is prime, and if you instead needed every prime up to some limit n, would your approach change? Junior level
  • Why can't you compute something like (base^exponent) mod m by raising to the power first and then taking the modulus, and how would you implement it correctly for large exponents — say in a crypto or hashing context?Go Pro Senior level
  • The Euclidean algorithm computes a GCD in O(log of the smaller input). Walk me through why it converges that fast and what input makes it work hardest.Go Pro Mid level
  • Some algorithm problems ask you to return an answer 'modulo 10^9 + 7', and binary search code often computes the midpoint as low + (high - low) / 2 instead of (low + high) / 2. What's the common concern behind both, and how do these patterns address it?Go Pro Junior level
  • You need (a^b) mod m where b is huge — say a 64-bit exponent. Why can't you just compute a^b and then take the modulus, and how would you do it correctly and efficiently?Go Pro Mid level
  • You need to test whether a 64-bit number is prime in a performance-sensitive service. Walk me through how you'd choose an approach, and why trial division usually isn't the answer at that scale.Go Pro Senior level
Want questions matched to your role? Paste a job title, job description, or CV for a personalized set, or go Pro to unlock the full bank.