Data Structures & AlgorithmsModerateTCS NQT Digital · Infosys

Problem: The words of "the sky is blue" are put in reverse order and joined by single spaces to form a new string. How many characters long is the new string?

  1. A. 12
  2. B. 4
  3. C. 15
  4. D. 16

Correct answer: C. 15

"blue is sky the" keeps 12 letters plus 3 spaces, 15 characters. Counting only letters gives 12, 4 is the word count, and adding a space after every word gives 16.

More Coding Interview Problems questions

Exams that ask this topic