Data Structures & AlgorithmsModerateTCS NQT · Accenture
Problem: A sparse-table-free query: over the array [5, 2, 8, 1, 9, 3, 7], what is the minimum value on the range of indices [2, 5] (inclusive)?
- A. 2
- B. 0
- C. 1
- D. 3
Correct answer: C. 1
A range minimum over an inclusive index range. Using the exclusive upper bound 5 misses index 5 and gives a larger value.
More Coding Interview Problems questions
- Problem: A Fenwick tree (binary indexed tree) over positions 1–8 starts with all zeros. The operations are: add 5 at position 3, add 4 at…
- Problem: Compute the 50th Fibonacci number F(50) with F(1) = F(2) = 1, modulo 1,000,000,007.
- Problem: Compute C(20, 10) modulo 1,000,000,007 (the binomial coefficient).
- Problem: How many prime numbers are there up to 100 (inclusive)?
- Problem: What is the LCM of the array [4, 6, 10, 15]?
- Problem: Count the pairs (i, j) with i < j in the array [1, 2, ..., 10] whose sum is divisible by 4.