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?
- 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
- 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
- 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
- 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
- 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
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.