InterviewDB Question

Optiver Graduate SWE 2025 OA Q1: Fast Modular Arithmetic Under Constraints

Question Details

Problem You are given two integers a and b and a prime modulus p. Compute (a^b) mod p efficiently. Then: given an array of n integers, compute the product of all elements modulo p, but skip any element that is divisible by p. Example: Follow-ups What is the time complexity of fast exponentiation? How does it compare to naive exponentiation for b = 10^18? By Fermat's little theorem, what is a^(p-1) mod p when p is prime and gcd(a,p)=1? How can this simplify computing modular inverses? If p is not…

Full Details

🔒

Unlock all Optiver questions

Full insider details, leaked discussions, and candidate experiences.

Get full access — $100 a year, unlimited access

About This Question

This is a reported interview question from a optiver interview for a swe role during the oa round.

It covers the following topics: Oa, Recursion, Coding, Arrays, Stack .