Data Structures & AlgorithmsModerateTCS NQT Digital · Accenture

Problem: The string "abcabc" is processed by replacing each character with its index in the alphabet (a=0, b=1, ..., z=25), and then the sum of the resulting numbers is computed. What is that sum?

  1. A. 12
  2. B. 3
  3. C. 6
  4. D. 588

Correct answer: C. 6

With a = 0, the letters give 0 + 1 + 2 + 0 + 1 + 2 = 6. Using a = 1 gives 12, processing only one "abc" gives 3, and summing ASCII codes gives 588.

More Coding Interview Problems questions

Exams that ask this topic