Data Structures & AlgorithmsHardCAT · TCS NQT
Problem: The sum of all three-digit palindromic numbers (100–999) is what value?
- A. 45450
- B. 494550
- C. 49500
- D. 90
Correct answer: C. 49500
Palindromes aba = 101a + 10b sum to 101 · 45 · 10 + 10 · 45 · 9 = 45450 + 4050 = 49500. Dropping the middle-digit part gives 45450, 494550 sums all three-digit numbers, and 90 is the count.
More Coding Interview Problems questions
- Problem: How many integers n with 0 ≤ n ≤ 255 have exactly four 1-bits in their binary representation?
- Problem: What is the largest power of 2 that is less than or equal to 1000?
- Problem: Find the smallest positive integer x such that floor(x/2) + x is at least 50.
- Problem: A set of jobs has deadlines and profits: (deadline 1, profit 20), (deadline 2, profit 40), (deadline 2, profit 30), (deadline 3…
- Problem: The insertion sort is applied to [3, 1, 2]. Count the total number of element moves (each shift of an element one place to the…
- Problem: Heap-indexed binary tree with 10 nodes (node i has children 2i and 2i+1 when ≤ 10). How many nodes lie at depth 2 (root at depth…