below which it cannot go. If the number of candies in the jar goes below , the jar must be refilled back to . A customer orders candies. If
def fib(n): if n <= 1: return n return fib(n-1) + fib(n-2)
In the TCS NQT (Ninja and Digital roles), the coding section has specific constraints you must know before writing a single line of code.
TCS does not award marks for compilation errors or runtime exceptions. Tcs Coding Questions 2021
While the hands-on coding section is important, the section is the filter that determines whether you reach the coding round at all. You have only 15 minutes to answer 10 questions . This section tests your theoretical and debugging skills on code snippets, often using C, C++, or Java. For example, you might be asked to predict the output of a loop with an unusual condition or identify the correct data structure. Mastering this section is non-negotiable for success.
Calculate the average for Trainee 1, Trainee 2, and Trainee 3. Find the maximum average among them. Filter out any trainee whose average is below 70.
Integer count.
High-level "Digital" roles often feature string manipulation or number theory. Problem Statement:
1 ≤ length of string ≤ 10⁵
def reverse_string(s): letters = [ch for ch in s if ch.isalpha()] letters.reverse() result = [] idx = 0 for ch in s: if ch.isalpha(): result.append(letters[idx]) idx += 1 else: result.append(ch) return ''.join(result) below which it cannot go
Tata Consultancy Services (TCS) is one of the largest IT consulting companies in the world, and it is a dream destination for many aspiring software engineers. To get hired by TCS, one needs to clear the TCS coding test, which is a critical stage in the recruitment process. In this article, we will provide you with a comprehensive guide to TCS coding questions 2021, including the types of questions asked, the format of the test, and some valuable tips to help you prepare.
Medium Marks: 15
def sieve(n): is_prime = [True]*(n+1) is_prime[0]=is_prime[1]=False for i in range(2,int(n**0.5)+1): if is_prime[i]: for j in range(i*i, n+1, i): is_prime[j]=False return is_prime If def fib(n): if n <= 1: return
The coding section in 2021 typically featured two problems: one of low-to-medium difficulty (Ninja level) and one of high difficulty (Digital level). To help you prepare, let’s dive into the most frequent topics and actual questions that appeared during the 2021 slots. Core Topics for TCS Coding 2021
Language Choice: C++ and Java are preferred for their speed, but Python is excellent for string manipulation and handling very large integers (common in TCS "Series" questions).