Coding Questions 2021 [better]: Tcs

def check_balance(s): stars = s.count('*') hashes = s.count('#') return stars - hashes # Test print(check_balance("###***")) # Output: 0 print(check_balance("##***")) # Output: 1 Use code with caution. 💡 Pro-Tips for Cracking TCS Coding Assessments

Based on memory-based results from the September 2021 drive, here are some of the most frequently reported coding questions: A. Number Problems & Digital Logic

Given an array, shift all zero elements to the end while maintaining the relative order of non-zero elements.

You are given an array of integers. Write a program to check if there are three consecutive even numbers or three consecutive odd numbers in the array. If found, print "True", otherwise print "False".

A bus starts from point A to point B. The cost of a ticket is calculated based on the following criteria: Tcs Coding Questions 2021

Given a positive integer, find its binary representation, toggle all bits after the Most Significant Bit (MSB) including the MSB, and print the resulting decimal number.

With 2021 as a reference, aspirants should focus on building strong basics, as TCS has continued a similar pattern in subsequent years (2022–2025) with slight variations in question count and difficulty.

Given a number N , calculate the sum of its prime factors.

Functions like malloc() , calloc() , and free() . def check_balance(s): stars = s

Q1 Solution: Sieve of Eratosthenes

Check if a given string or number is a palindrome. Fibonacci Series: Find the N-th Fibonacci number. B. Array Manipulation

Simplicity and correctness matter more than fancy solutions in TCS NQT coding round.

Remember, the best way to prepare is to code consistently. Review these topics, practice writing full programs from scratch to handle input/output correctly, and you'll turn this "unknown" into a successful opportunity. Good luck! You are given an array of integers

This public link is valid for 7 days and shares a thread, including any personal information you added. This link or copies made by others cannot be deleted. If you share with third parties, their policies apply. Can’t copy the link right now. Try again later.

TCS does not invent entirely new problems every year. The set is a blueprint. The prime-checking logic, the string group counting, the coin problem with a twist—these concepts reappear in 2023, 2024, and will continue.

After analyzing 50+ student reports, here are the recurring themes: