Data Structures & AlgorithmsModerateTCS NQT · Infosys
Problem: Intervals [1,4], [3,8], [6,9], [10,12], [2,5] are given. How many of them contain the point 5 (endpoints included)?
- A. 3
- B. 2
- C. 1
- D. 4
Correct answer: B. 2
Check each closed interval for containing the point. Endpoints count, so [2,5] qualifies even though 5 is its right end.
More Coding Interview Problems questions
- Problem: Compute (1³ + 2³ + … + 100³) modulo 1000.
- Problem: A trie stores the words "apple", "app", "apply", "ape", "banana". How many stored words start with the prefix "app" (including a…
- Problem: Subtraction game: from n stones a player may remove 1, 3 or 4 stones; the player who cannot move loses (no stones left on their…
- Problem: On the 4-cycle C4 (vertices 0-1-2-3-0), a walker starts at 0 and takes exactly 3 steps, each to an adjacent vertex. How many…
- Problem: The array [7, 3, 9, 1, 5] is processed by a selection that finds the position of the maximum, removes it, and repeats. The…
- Problem: How many 4-digit numbers (1000–9999) are palindromes (read the same forwards and backwards in decimal)?