Tcs Coding Questions 2021 Access
Difficulty: Easy
Marks: 10
Statement:
Given a string containing alphabets and special characters (e.g., @, #, $, !), reverse only the alphabetic characters while keeping special characters in their original positions.
Example:
Input: "a,b$c"
Output: "c,b$a"
Constraints:
1 ≤ length of string ≤ 10⁵
Input format:
Single line string S.
Output format:
Modified string.
Sample Input:
"A@b#c$D"
Sample Output:
"D@c#b$A"
Problem Statement:
An international organization defines a "Prime Minister" number as a positive integer greater than 10 that satisfies two conditions:
Given an array of integers, print the count of such "Prime Minister" numbers.
Example:
Input: [11, 23, 41, 29, 56]
Output: 3 (Because 11→1+1=2(prime), 23→2+3=5(prime), 41→4+1=5(prime), 29 is prime but 2+9=11(prime) actually also qualifies—so 4? Wait: 56 is not prime. So output is 4). Tcs Coding Questions 2021
Solution (Python):
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 Truedef digit_sum(n): return sum(int(d) for d in str(n))
arr = list(map(int, input().split())) count = 0 for num in arr: if num > 10 and is_prime(num) and is_prime(digit_sum(num)): count += 1 print(count)
Why this was asked in 2021: Tests nested function calls and primality checking within constraints (n ≤ 10^6). Difficulty: Easy Marks: 10 Statement: Given a string
Introduction: The Gatekeeper of an IT Dream
For millions of engineering graduates in India, Tata Consultancy Services (TCS) represents more than just a job—it is a career launchpad. As the largest private-sector employer in the country, TCS conducts its National Qualifier Test (NQT) yearly. While the exam pattern evolves, the coding section remains the highest-scoring and most decisive part.
If you are searching for TCS Coding Questions 2021, 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.
In this article, we will dissect the TCS Coding Questions from 2021, categorize them by difficulty, provide step-by-step solutions, and share strategies to crack the automatic evaluator.