Data Structures & AlgorithmsModerateSSC CGL Tier 2 · TCS NQT
Problem: Compute the sum of the digits of the number 2^20 × 5^18 written in decimal.
- A. 5
- B. 3
- C. 6
- D. 4
Correct answer: D. 4
Since 2^20 × 5^18 = 2² × 10^18, its decimal form is 4 followed by 18 zeros, so the digit sum is 4. Multiplying out small pieces without simplifying works but invites arithmetic slips.
More Coding Interview Problems questions
- Problem: Let f(n) = number of 1-bits in n. Compute Σ f(n) for n from 0 to 63 inclusive.
- Problem: Starting at (0,0), the robot moves in the string "NNEESSWWNE" with N = up, E = right, S = down, W = left. Count the number of…
- Problem: The sequence a1 = 2, and each next term is a(n+1) = (a(n) × 3 + 1) mod 11. What is a(20)?
- Problem: A bag holds coins of values 1, 4 and 9. You must pay exactly 30 using as few coins as possible. What is the minimum number of…
- Problem: The 0/1 matrix [[1,0,1],[1,1,0],[0,1,1]] is considered. A 'plus' is a centre cell with value 1 whose four neighbours (up, down…
- Problem: Two heaps are maintained over the stream 5, 15, 1, 3, 8, 7, 9, 10, 6, 11 to report the median after each element (lower median…