Data Structures & AlgorithmsModerateTCS NQT · Infosys

Problem: From the string "3a7b2c" the digits are extracted and summed. What is the sum of the digits?

  1. A. 12
  2. B. 3
  3. C. 42
  4. D. 372

Correct answer: A. 12

The digit characters are 3, 7, 2, and 3 + 7 + 2 = 12. Counting them gives 3, multiplying gives 42, and concatenating them into a number gives 372.

More Coding Interview Problems questions

Exams that ask this topic