Data Structures & AlgorithmsModerateTCS NQT · Infosys
Problem: From the string "3a7b2c" the digits are extracted and summed. What is the sum of the digits?
- A. 12
- B. 3
- C. 42
- 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
- Problem: The number of ways to place 3 identical red balls and 2 identical blue balls in a row of 5 positions is what value?
- Problem: The matrix [[1,2],[3,4]] is raised to the power 3 (matrix multiplication, not element-wise). What is the entry in row 0, column 0…
- Problem: Starting from the empty binary string, the value of the string "1011" read in base 2 is computed, then 3 is added. What is the…
- Problem: A list is [5, 9, 2, 7]. How many pairs (i, j) with i < j have a[i] + a[j] greater than 10?
- Problem: For the words ["sleep", "steep", "sheep", "creep"] (all of length five), how many unordered pairs differ in exactly one letter…
- 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…