Tcs: Coding Questions 2021

Input: listen silent → Output: True

Three trainees run a fitness test. The test lasts for 3 rounds. In each round, the oxygen levels of all 3 trainees are recorded. Calculate the average oxygen level for each trainee.

: Given a number (up to 100 digits), find the difference between the sum of digits at odd and even positions. Jar of Candies : A JAR has a capacity . Given an order for candies, update the JAR count. If

First line: N K Second line: N integers.

Single line string S.

This was a "modified greedy" problem that required recursion or DP.

brute-force solutions will usually time out. Practice optimizing your code to using techniques like prefix sums, hash maps, and sorting.

Write a program to calculate the total fare based on the distance traveled.

Finding the Nth term in mixed numeric series (e.g., a series that alternates between Fibonacci and Prime numbers).

The TCS NQT coding round in 2021 emphasized clear, logical thinking over arcane knowledge. By focusing on key topics like array and string manipulation, number theory basics, and pattern recognition, and practicing with a structured approach, you can confidently tackle these challenges.

Logic: Write an isPrime() function and a digitSum() function.

Rearrange an array such that all even numbers are at the beginning followed by all odd numbers. The relative order of even/odd numbers does not need to be maintained.

Mastering TCS Coding Questions 2021: Your Ultimate Preparation Guide

int main() int arr[] = 12, 35, 1, 10, 34, 1; int n = sizeof(arr)/sizeof(arr[0]);

Input: 1 2 3 4 5 6 7 8 9 10 11 12 Output: 1 2 3 4 8 12 11 10 9 5 6 7

while fast and fast.next: slow = slow.next fast = fast.next.next

| Component | Details | |-----------|---------| | | 1 or 2 coding problems | | Time Allotted | 15–20 minutes (for coding) | | Languages Allowed | C, C++, Java, Python, Perl | | Difficulty | Easy to Medium | | Topics Covered | Arrays, Strings, Loops, Conditionals, Basic Math, Recursion |

TCS Coding Questions 2021: Top Problems and Preparation Guide