Data Structures & AlgorithmsModerateTCS NQT Digital · CAT
Problem: Compute the sum of all integers from 1 to 999 whose digits are all odd.
- A. 250000
- B. 155
- C. 69375
- D. 70775
Correct answer: D. 70775
Numbers with only odd digits (5 + 25 + 125 = 155 of them) sum to 70775. Checking only the last digit sums all odd numbers to 250000, 155 is the count, and 69375 covers only the 3-digit ones.
More Coding Interview Problems questions
- Problem: What is the number of ways to climb 8 steps when each move is 1, 2 or 4 steps, counted as ordered sequences?
- Problem: The array [1, 2, 3, 4, 5, 6, 7, 8, 9] is split into 3 consecutive groups of equal length. What is the sum of the middle group?
- Problem: The product of the numbers from 1 to 10, divided by the product of the numbers from 1 to 7, is what value?
- Problem: A string is "xoxoxox". How many substrings of length 3 are equal to "xox"?
- Problem: Consider the graph on vertices 1–6 with edges 1-2, 2-3, 3-4, 4-1, 5-6. What is the size of its largest connected component?
- Problem: Starting at index 0 of the array [2, 4, 1, 6, 3], repeatedly jump forward by the value at the current index (no wraparound; the…