Data Structures & AlgorithmsModerateTCS NQT · Infosys
Problem: The string "abcdefghij" is split into blocks of length 4 from the left (the last block may be shorter). How many blocks have their first letter as a vowel (a, e, i, o, u)?
- A. 3
- B. 4
- C. 2
- D. 5
Correct answer: A. 3
The blocks begin at indices 0, 4 and 8 with letters a, e and i, all vowels, so the answer is three.
More Coding Interview Problems questions
- Problem: The number of permutations of the digits 1, 2, 3, 4 in which the digit 1 is not in the first position and 4 is not in the last…
- Problem: Cars pass a toll booth at times 2, 5, 6, 10, 11, 15 (minutes). A car may pass only if at least 3 minutes have elapsed since the…
- Problem: A sorted list of distinct integers is 3, 8, 12, 17, 21, 26, 30. How many pairs (i < j) have a[j] − a[i] exactly equal to 9?
- Problem: The value of 3^(3^3) mod 7 is what?
- Problem: A path graph has vertices 1–6 with edges between consecutive vertices. How many pairs of vertices are at distance exactly 2?
- Problem: Consider the directed graph with arcs 1→2, 2→3, 3→4, 4→2, 1→5. Starting from 1, how many distinct vertices are reachable…