def is_prime(n): if n < 2: return False for i in range(2, int(n**0.5)+1): if n % i == 0: return False return True def digit_sum(n): return sum(int(d) for d in str(n))
If you are searching for , you are likely preparing for the TCS NQT (National Qualifier Test) or the TCS Ninja/Digital hiring rounds. Although 2021 was a few years ago, those questions remain a goldmine of practice. Why? Because TCS recycles logic. The syntax of the language may change, but the algorithmic patterns—arrays, strings, greedy algorithms, and mathematical puzzles—remain timeless. Tcs Coding Questions 2021
Wait—The actual TCS 2021 version was simpler: Replace all non-overlapping "WWW" with "F". But overlapping should remain. def is_prime(n): if n < 2: return False