Knapsack variants, coin change problems, and job scheduling. High-Frequency TCS 2021 Coding Questions & Solutions
def rearrange_array(arr): even = [x for x in arr if x % 2 == 0] odd = [x for x in arr if x % 2 != 0] return even + odd # Example Usage arr = [1, 2, 3, 4, 5, 6] print(rearrange_array(arr)) # Output: [2, 4, 6, 1, 3, 5] Use code with caution. 4. Tips to Crack TCS Coding Tests
7 7 3 2 4 9 12 56 3
def first_non_repeating_char(s): char_count = {} for char in s: if char in char_count: char_count[char] += 1 else: char_count[char] = 1 Tcs Coding Questions 2021
Palindrome checking, anagrams, substring searching, character frequency counting, and string tokenization.
TCS problems heavily penalize code that fails to account for bound limits, negative indices, or structural formatting anomalies in raw standard inputs. Time Complexity Thresholds: Brute-force solutions targeting
In addition to coding, students often faced technical MCQs focused on : Knapsack variants, coin change problems, and job scheduling
Problem Description: Given an array Arr[] of N integers and a positive integer K, cyclically rotate the array clockwise by K elements. Keep the first element of the array unaltered.
Example:
: Given a number (up to 100 digits), find the difference between the sum of digits at odd and even positions. Jar of Candies : A JAR has a capacity . Given an order for candies, update the JAR count. If Tips to Crack TCS Coding Tests 7 7
1 ≤ N ≤ 10⁵
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.
Print the trainee numbers (1, 2, or 3) matching the maximum average. Python Code:
Three trainees are performing a physical task for three rounds. You receive nine oxygen level inputs. You must calculate the average for each trainee and identify who has the highest average. If an average is below 70, the trainee is unfit. Key Logic: Group inputs by trainee (Trainee 1: inputs 1, 4, 7). Calculate the average for each. Compare averages to find the maximum. Handle the "Unfit" case if all averages are below 70. 3. String Caesar Cipher Variation