Data Structures & AlgorithmsModerateTCS NQT · Accenture
Problem: How many 4-digit numbers (1000–9999) are palindromes (read the same forwards and backwards in decimal)?
- A. 100
- B. 900
- C. 81
- D. 90
Correct answer: D. 90
Choose the first digit (1..9) and the second (0..9); the last two mirror them, so 9 × 10 = 90. Allowing a leading 0 gives 100, 900 counts 5-digit palindromes, and 81 wrongly bans 0 in the second digit.
More Coding Interview Problems questions
- Problem: The string "abcabcabc" has how many distinct substrings of length 3?
- Problem: What is the number of walks of length 4 that start and end at the same vertex in the complete graph K3 (vertices 0, 1, 2, each…
- Problem: How many integers in [1, 999] have digits that are strictly increasing (each digit larger than the previous)? Run the code…
- Problem: What is the sum of the first 50 terms of the sequence 1, 1, 2, 3, 5, ... (Fibonacci numbers F(1) to F(50), with F(1)=F(2)=1)? Run…
- Problem: How many pairs (i < j) of [2, 4, 6, 9, 12, 15] have gcd(ai, aj) = 3? Run the code. python from math import gcd a = [2, 4, 6, 9…
- Problem: How many integers in [1, 300] are divisible by exactly two of the numbers 2, 3 and 5? Run the code. python print(sum(1 for x in…