Data Structures & AlgorithmsModerateTCS NQT · Accenture
Problem: Start with 7, multiply it by 3, then repeatedly replace the number by the sum of its decimal digits until a single digit remains. What digit results?
- A. 4
- B. 2
- C. 3
- D. 5
Correct answer: C. 3
Multiply once, then reduce by digit sums until a single digit remains. Repeatedly multiplying by 3 without the digit-sum step gives a huge number, not a digit.
More Coding Interview Problems questions
- Problem: The array [4, 1, 3, 2, 5] is processed by counting sort on the values 1 to 5, writing the values into an output array in sorted…
- Problem: For the set {2, 3, 4, 6, 8, 9, 12}, how many pairs (x, y) with x < y have x dividing y?
- Problem: A bag contains 2 red, 3 green and 4 blue balls. How many ways are there to choose 3 balls so that all three have different colours?
- Problem: The string "abcdefghij" is read two letters at a time in pairs; each pair (xy) is replaced by the pair reversed (yx). What is the…
- Problem: The sum of the numbers in the sequence 1, 1+2, 1+2+3, …, up to 1+2+…+12 is what value?
- Problem: In the array [2, 4, 6, 8, 10], count the number of subarrays whose sum is divisible by 4.