Tcs Coding Questions 2021 !full! -
Difficulty breakdown (approximate)
Tiebreaker: If multiple trainees have the same highest average, display all of them.
Write a program to test if a given input string is a valid keyword in a specific language subset. The standard keywords predefined in the system are: break, case, continue, default, defer, else, for, func, goto, if, map, range, return, select, struct, switch, type, var . Input Format A single string token. Output Format [string] is a keyword or [string] is not a keyword . Solution Template (C++)
def check_keyword(word): keywords = "break", "case", "continue", "default", "defer", "else", "for", "func", "goto", "if", "map", "range", "return", "struct", "switch", "type", "var" if word in keywords: return f"word is a keyword" else: return f"word is not a keyword" # Driver Code if __name__ == "__main__": user_input = input().strip() print(check_keyword(user_input)) Use code with caution. 2. The Oxygen Level Problem (Selection Logic) Problem Statement Tcs Coding Questions 2021
Reverse the words in a given sentence while keeping the word order the same. Remove Vowels: Remove all vowels from a string.
| Category | Specific Topics & Questions | | :--- | :--- | | | • Odd/Even sums : Difference between sum of odd and even position digits of a large number (up to 100 digits). • Base conversion : Convert numbers from base 17 (using A=10, B=11, ... G=16) to decimal. • HCF, LCM, GCD calculations. • Checking for Prime Numbers , Palindrome Numbers , Armstrong Numbers , and Automorphic Numbers . • Generating Fibonacci and Factorial (using recursion) series. | | 👉 Array & String Manipulation | • Core operations : Find max/min, second largest, reverse array, remove duplicates, and rotate array by K elements. • String manipulations : Reverse a string, count word frequency, and check for palindromes. • Advanced concepts : Working with camel case strings and dynamic programming problems (for TCS Digital). | | 👉 Pattern Recognition & Series | • Pattern 1 : A series mixing two different sequences (e.g., 0, 0, 2, 1, 4, 2, 6, 3... ) combining natural numbers and their halves. • Pattern 2 : Recognizing series that interleave geometric progressions for odd/even positions. | | 👉 Real-World Scenarios & Puzzles | • Candy Jar Problem : Simulate a candy jar with capacity N, sell candies while ensuring it never goes below K, refilling when necessary. • Special Number Searches : Find the smallest N-digit number with no zero digit where the sum of squares of its digits is a perfect square. • Matrix Manipulation : Find the largest element and move it to the center by swapping with adjacent elements. |
To master the "TCS Coding Questions 2021" pattern, follow this 3-week plan: Input Format A single string token
Tips for using the set effectively
To prepare effectively for questions like those seen in 2021:
One programming language has a fixed set of keywords: break, case, continue, default, defer, else, for, func, goto, if, map, range, return, struct, switch, type, var . Write a program to determine if a given string input is a keyword or not. A single string. advanced graph theory
Iterate through the string. If a character is present in the set of vowels, skip it; otherwise, add it to the result.
TCS often tests basic syntax matching. Write a program to determine if a given string is a reserved keyword in a mock language. The keywords are: break, case, continue, default, defer, else, for, func, goto, if, map, range, return, struct, type, var . Input : defer Output : defer is a keyword Input : hello Output : hello is not a keyword Python 3 Implementation
Given a number N , calculate the sum of its prime factors.
Medium to High. Questions heavily featured dynamic programming, greedy algorithms, advanced graph theory, and complex data structures. Core Syllabus and Key Archetypes
public class Main public static void main(String[] args) Scanner sc = new Scanner(System.in); int dist = sc.nextInt(); int fare = 0;

