Tcs Coding Questions 2021 Link

Here are some TCS coding questions from 2021, along with a useful piece of code for each:

Format: Floating-point numbers must match the specified precision exactly (e.g., %.2f for two decimal places). Tcs Coding Questions 2021

int first_large = INT_MIN, second_large = INT_MIN;
int first_small = INT_MAX, second_small = INT_MAX;
  1. Question Recycling: TCS has a massive question bank. Approximately 40% of coding problems from 2021 resurface in later years with swapped variable names.
  2. Pattern Consistency: The core topics—Arrays (60%), Strings (30%), and Basic Mathematics (10%) —have remained unchanged since 2021.
  3. Difficulty Ceiling: In 2021, TCS introduced the "one logic twist" (e.g., removing one character from palindrome). That twist remains the standard.
// For smallest if(arr[i] < first_small) second_small = first_small; first_small = arr[i]; else if(arr[i] < second_small && arr[i] != first_small) second_small = arr[i];

Statement:
Given an array of N integers and an integer K, find the number of unique pairs (i, j) with i < j such that arr[i] + arr[j] = K. Here are some TCS coding questions from 2021,

  • The reversed integer M.

: Finding the second largest/smallest element, rotating an array by positions, and finding missing numbers in a sequence. String Manipulation Question Recycling: TCS has a massive question bank

Problem Statement:
Given an m x n matrix, print all elements in spiral order starting from the top-left corner moving right, then down, then left, then up.