Data Structures & AlgorithmsModerateTCS NQT · Accenture
Problem: In the array [9, 2, 6, 4, 7, 1], what is the number of elements that are smaller than every element to their left (strict left minima, with the first element counted)?
- A. 4
- B. 2
- C. 5
- D. 3
Correct answer: D. 3
Count the running minimum records: 9, then 2, then 1. The values 6, 4 and 7 are not smaller than the running minimum at their positions.
More Coding Interview Problems questions
- Problem: The number 2^10 − 1 has how many distinct prime factors?
- Problem: A text buffer contains "hello world". Each space is replaced by the three characters "%20" (URL-style encoding). What is the…
- Problem: The bitwise AND of all integers from 12 to 15 inclusive is computed. What is the result?
- Problem: A row of 5 seats is filled by 3 distinct people, leaving 2 seats empty. How many arrangements are possible if the empty seats…
- Problem: The sum of the squares of the odd numbers from 1 to 19 is what value?
- Problem: A grid of 3 rows and 3 columns is filled with the numbers 1 to 9 row by row. A "line" is a complete row, column or main diagonal…