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)?

  1. A. 3
  2. B. 4
  3. C. 2
  4. 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

Exams that ask this topic