Tcs Coding Questions 2021 [top]
n = int(input()) for i in range(n): print(fib(i), end=" ")
for char in S: # ASCII logic: 'a' is 97. Subtract 97 to get 0-25 range. # Add K, take modulo 26 to wrap around, add 97 back. new_char = chr(( (ord(char) - 97 + K) % 26) + 97) res += new_char
: Given two non-negative integers n1 and n2 , find the count of all numbers in the range from n1 to n2 (inclusive) that have no repeated digits . Example : n1=11 , n2=15 . The numbers 12, 13, 14, 15 have no repeated digits. So, the output is 4 . Sample Solution (C++) :
If all trainees are unfit (average < 70), display "All trainees are unfit". Tcs Coding Questions 2021
Selection of trainees for a fitness program requires measuring their oxygen levels over three consecutive rounds. Three trainees run the test. The trainee with the highest average oxygen level over the three rounds is selected.
While Ninja rounds allow
This classic condition-based question appeared in multiple 2021 slots. It tests your ability to handle basic input-output and constraints. Problem Statement: A jar has a capacity At any point, it has If a customer orders candies, you must update the jar. Refill Rule: n = int(input()) for i in range(n): print(fib(i),
Array bounds (e.g., checking i+1 without exceeding the array size). 3. Focus on Time Complexity
45 minutes total (15 minutes for the first question, 30 minutes for the second).
Your performance directly determines your profile: new_char = chr(( (ord(char) - 97 + K)
#include <iostream> using namespace std;
| 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 |
To consistently clear the benchmark scores observed in the 2021 placement windows, adopt the following structured approach:
Dynamic Programming: Basic optimization problems and pathfinding. Conditionals: Nested logic and coordinate geometry. Solved Examples from TCS 2021 Slots 1. The Keyword "Sweet Number" (Array/Math)
Input: 13 (1101) → Output: 3. while(n) count++; n = n & (n-1);