Data Structures & AlgorithmsModerateTCS NQT Digital · Product Company SDE
Problem: What is the smallest integer x with x·x ≥ 1,000,000,000?
- A. 31623
- B. 31622
- C. 1000
- 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
- Problem: A grid holds oranges: 2 = rotten, 1 = fresh, 0 = empty: [[2,1,1],[1,1,0],[0,1,1]]. Each minute every fresh orange adjacent…
- Problem: Courses 0–5 have prerequisites: 1 needs 0, 2 needs 1, 3 needs 2, 4 needs 5, 5 needs 4. A course can be taken only after all its…
- Problem: Buses run fixed routes; from a stop, the number of distinct routes is what matters. Given the four routes [1,2,7], [3,6,7]…
- Problem: In the array [3, 1, 4, 1, 5, 9, 2, 6] an element is visible from the left if it is strictly greater than every element before it…
- Problem: Find the area of the largest rectangle in a histogram with bar heights [2, 1, 5, 6, 2, 3] (each bar has width 1).
- Problem: Remove exactly 3 digits from the number "1432219" to make the smallest possible number (leading zeros are not allowed in the…