Tcs Coding Questions 2021 File

Tata Consultancy Services (TCS) is one of the largest IT services companies in the world. Every year, lakhs of engineering students and software aspirants compete for a coveted role at TCS through placement drives like TCS NQT (National Qualifier Test) and TCS Digital.

#include <stdio.h>

Q1 Solution: Sieve of Eratosthenes

for(int i = 0; i < n; i++) // For largest if(arr[i] > first_large) second_large = first_large; first_large = arr[i]; else if(arr[i] > second_large && arr[i] != first_large) second_large = arr[i]; Tcs Coding Questions 2021

Tata Consultancy Services (TCS) is one of the largest global IT services providers, attracting hundreds of thousands of engineering graduates every year. The 2021 recruitment drives—primarily conducted through the TCS National Qualifier Test (NQT) and TCS Digital exams—marked a significant shift toward automated, multi-tiered coding assessments.

Example:

Input: [3, 4, -1, 1] → Output: 2

45 minutes total (15 minutes for the first question, 30 minutes for the second).

"A@b#c$D"

Focus heavily on Arrays, Strings, and basic Mathematics in C++ or Python. Tata Consultancy Services (TCS) is one of the

Solve in O(1) extra space.

You might ask: "Why study 2021 questions if the exam is in 2025/2026?" Here is the truth about TCS:

Move all zeros in an array to the end while maintaining the order of non-zero elements. Solve in O(1) extra space