Data Structures & AlgorithmsModerateSSC CGL Tier 2 · TCS NQT
Problem: What is the sum of the decimal digits of 9⁹?
- A. 0
- B. 27
- C. 45
- D. 9
Correct answer: C. 45
9⁹ = 387420489, whose digits sum to 45. Writing 9 ^ 9 in Python is XOR and gives 0, mixing it up with 9! = 362880 gives 27, and the digital-root shortcut only says the sum is a multiple of 9 (repeatedly summing gives 9).
More Coding Interview Problems questions
- Problem: Arrange the numbers 3, 30, 34, 5, 9 so that their decimal concatenation is the largest possible number. What is that largest…
- Problem: Minimum number of jumps to reach the last index of [2, 3, 1, 1, 4] when from index i you may jump up to a[i] steps forward. What…
- Problem: Find the k-th largest element of [3, 2, 1, 5, 6, 4] for k = 2 (1-indexed among values, with duplicates counted separately).
- Problem: The intervals [1,3], [2,4], [3,6], [7,8], [5,9], [8,10] are given. What is the minimum number of intervals to remove so that the…
- Problem: Find the number of unique triplets (as value sets) that sum to zero in [−1, 0, 1, 2, −1, −4].
- Problem: How many substrings of "eceba" contain exactly 2 distinct characters?