Data Structures & AlgorithmsModerateTCS NQT Digital · Product Company SDE

Problem: What is the smallest integer x with x·x ≥ 1,000,000,000?

  1. A. 31623
  2. B. 31622
  3. C. 1000
  4. D. 100000

Correct answer: A. 31623

31622² = 999,950,884 < 10⁹ and 31623² = 1,000,014,129, so the answer is 31623 (binary search for the first x with x·x ≥ n). The floor square root 31622 is the classic off-by-one, 1000 is the cube root, and 100000 is √10¹⁰.

More Coding Interview Problems questions

Exams that ask this topic