Data Structures & AlgorithmsModerateTCS NQT · Accenture

Problem: The string "ABCABCABC" is read and each letter is replaced by its position in the alphabet (A=1, B=2, C=3). What is the sum of the first 5 resulting numbers?

  1. A. 9
  2. B. 18
  3. C. 12
  4. D. 6

Correct answer: A. 9

The first five letters A, B, C, A, B map to 1 + 2 + 3 + 1 + 2 = 9. All nine letters sum to 18, the first six to 12, and the first three to 6.

More Coding Interview Problems questions

Exams that ask this topic