Data Structures & AlgorithmsModerateTCS NQT · basics
Problem: What is the sum of the digits of 2^10 = 1024? Run the code.
Problem: What is the sum of the digits of 2^10 = 1024? Run the code.
print(sum(int(c) for c in str(2 ** 10)))What is printed?
- A. 6
- B. 8
- C. 10
- D. 7
Correct answer: D. 7
1 + 0 + 2 + 4 = 7. Summing the digits of 2^9 instead would give 8, a small slip to avoid.
More Coding Interview Problems questions
- Problem: What is the product of the distinct elements of [2, 2, 3, 4, 4]? Run the code. python a = [2, 2, 3, 4, 4] p = 1 for x in set(a)…
- Problem: What is the minimum absolute difference between two values of the sorted list [1, 5, 6, 9]? Run the code. python a = sorted([1…
- Problem: How many 2-element subsets of {1, 2, 3, 4, 5} have an even sum? Run the code. python from itertools import combinations…
- Problem: Which statement about the sparse table data structure for static range-minimum queries is correct?
- Problem: Which statement about heavy-light decomposition for path queries on a tree is correct?
- Problem: Which statement about Fermat's little theorem is correct?