Tcs Coding Questions 2021 May 2026

Many lost marks by using replace() in Python without controlling overlap. Question 3: The "Autobiographical Number" (Digit Frequency) Problem Statement: An autobiographical number is an integer N such that the first digit (from left) counts how many zeros are in N, the second digit counts how many ones, and so on. Given a number (as a string), verify if it's autobiographical.

Q2 Solution: String reversal

Q1 Solution: Sieve of Eratosthenes

Wait—The actual TCS 2021 version was simpler: Replace all non-overlapping "WWW" with "F". But overlapping should remain. Tcs Coding Questions 2021

M=13. Standard greedy: 10+3 = 2 coins. But remainder after 10 =3 (divisible by 3) → forbidden. So you must choose 5+5+3 =3 coins. Many lost marks by using replace() in Python