TCS coding questions in 2021 focused on fundamentals rather than advanced algorithms. If you can solve string manipulations, basic array problems, and number series, you can easily clear the coding section. Practice consistently on platforms like TCS iON, CodeChef, or HackerRank under timed conditions.
Key takeaway: Simplicity and correctness matter more than fancy solutions in TCS NQT coding round.
The 2021 TCS National Qualifier Test (NQT) coding paper typically featured two questions, ranging from easy array manipulation to intermediate dynamic programming, within a 45-60 minute timeframe. Common topics included string character counting, series generation (mixed powers of 2 and 3), and coordinate geometry, according to PrepInsta and TakeUForward. You can explore the full, detailed archives of these 2021 solved papers on PrepInsta.
In 2021, the TCS NQT (National Qualifier Test) coding section typically consisted of two problems: one of easy-to-medium difficulty (to be solved in 15 minutes) and one of advanced difficulty (to be solved in 30 minutes)
. These questions often focused on mathematical series, string manipulation, and array-based logic. takeUforward 1. Common Coding Questions (2021)
Based on various slot reports from 2021, here are the most frequent problem types and specific examples:
The TCS National Qualifier Test (NQT) in 2021 followed a specific pattern where candidates were typically given two coding questions of varying difficulty levels
. The primary categories for these questions include array manipulation, string processing, and number theory. takeuforward 1. Exam Pattern & Syllabus (2021)
The coding section is usually divided into two parts based on the targeted role (Ninja or Digital/Prime): Great Learning Foundation Coding:
1 question to be solved in 15–30 minutes, focusing on basic logic and data types. Advanced Coding: Tcs Coding Questions 2021
2 questions with a shared time limit of 90 minutes, requiring knowledge of advanced data structures and algorithms. Allowed Languages: C, C++, Java, Python, and Perl. 2. Most Asked Coding Questions in 2021
Based on previous year papers, the following are common problem statements: Key Problem Types Second smallest/largest, rotation by , symmetric pairs, max product subarray.
Palindromes, vowel/consonant count, first non-repeating character, partitioning strings. Number Theory
Prime/Armstrong/Harshad numbers, GCD/LCM, Fibonacci series, base conversion. Scenario-Based
Problems like "Washing Machine" (time calculation based on weight) or "Oxygen Level" (comparing trainee performance). 3. Sample Logic (Unique Digit Counter) Count numbers with non-repeating digits in range
Iterate through the range, convert each number to a string, and check if the count of unique characters equals the total character count. 4. Key Preparation Resources (Most Asked) TCS NQT Coding Questions and Answers 2021
Here are some TCS coding questions from 2021, along with a useful piece of code for each:
1. Find the first non-repeating character in a string
Given a string, find the first non-repeating character in it. TCS Coding Questions 2021: A Complete Analysis TCS
Example: Input - "aabbc", Output - "c"
def first_non_repeating_char(s):
char_count = {}
for char in s:
if char in char_count:
char_count[char] += 1
else:
char_count[char] = 1
for char in s:
if char_count[char] == 1:
return char
return None
print(first_non_repeating_char("aabbc")) # Output: "c"
2. Check if a string is a palindrome
Given a string, check if it's a palindrome or not.
Example: Input - "madam", Output - True
def is_palindrome(s):
return s == s[::-1]
print(is_palindrome("madam")) # Output: True
3. Find the maximum sum of a subarray
Given an array of integers, find the maximum sum of a subarray.
Example: Input - [-2, 1, -3, 4, -1, 2, 1, -5, 4], Output - 6
def max_subarray_sum(arr):
max_sum = float('-inf')
current_sum = 0
for num in arr:
current_sum = max(num, current_sum + num)
max_sum = max(max_sum, current_sum)
return max_sum
print(max_subarray_sum([-2, 1, -3, 4, -1, 2, 1, -5, 4])) # Output: 6
4. Count the number of pairs with a given sum
Given an array of integers and a target sum, count the number of pairs with that sum. max_ending_here = max_so_far = arr[0] For each next:
Example: Input - [1, 2, 3, 4, 5], target sum - 7, Output - 2
def count_pairs_with_sum(arr, target_sum):
count = 0
seen = set()
for num in arr:
complement = target_sum - num
if complement in seen:
count += 1
seen.add(num)
return count
print(count_pairs_with_sum([1, 2, 3, 4, 5], 7)) # Output: 2
5. Find the middle element of a linked list
Given a linked list, find the middle element.
Example: Input - 1 -> 2 -> 3 -> 4 -> 5, Output - 3
class Node:
def __init__(self, data):
self.data = data
self.next = None
def find_middle_element(head):
slow = head
fast = head
while fast and fast.next:
slow = slow.next
fast = fast.next.next
return slow.data
# Create a sample linked list: 1 -> 2 -> 3 -> 4 -> 5
head = Node(1)
head.next = Node(2)
head.next.next = Node(3)
head.next.next.next = Node(4)
head.next.next.next.next = Node(5)
print(find_middle_element(head)) # Output: 3
This report summarizes the coding questions and exam pattern for the 2021 TCS National Qualifier Test (NQT). The 2021 recruitment cycle introduced several specific problem types focused on basic data structures and real-world scenario modeling. 1. Exam Overview (2021 Cycle)
The 2021 TCS NQT followed a structured format where the coding section was pivotal for both "Ninja" and "Digital" hiring profiles. Number of Questions: 2.
Time Allotted: Approximately 45 to 90 minutes, depending on the specific slot and hiring category. Permitted Languages: C, C++, Java, Python, and Perl. Platform: TCS iON or CodeVita platform. 2. Core Coding Topics
Analysis of 2021 slots shows that questions primarily tested foundational logic rather than advanced competitive programming: TCS NQT Most Repeated Coding Questions | PDF - Scribd
Question 1 (15 marks):
Write a program to remove duplicate characters from a string without using an extra data structure (like set). Print the resulting string.
Test case: "programming" → "progamin"
Question 2 (25 marks):
You are given an array of heights of students. Find the minimum number of jumps required to reach the end of the array, where you can jump from index i to i+1, i+2, or i+3, but you cannot land on an index where the height is greater than the current height.
This was the "killer" problem in TCS Digital December 2021.