Tcs Coding Questions 2021 Now
A JAR has capacity N. It starts with M candies (M ≤ N). As customers order, candies are sold, and the JAR is refilled if candies are less than k. Given input (candies ordered), display the number of candies sold and the remaining candies. If orders exceed capacity, output "INVALID INPUT".
Binary search variations, custom sorting (sorting based on specific criteria), and greedy selection.
Example:
: Given an array Arr[ ] of N integers and a positive integer K , the task is to cyclically rotate the array clockwise by K . Note: Keep the first element of the array unaltered. Example : Tcs Coding Questions 2021
Below are some of the most frequently asked coding questions from the 2021 batches, complete with logic breakdowns and optimized Python solutions. Question 1: The Sweet Jar (Array / Greedy) Given a jar filled with number of candies. The jar has a minimum capacity
Focused on basic data structures, array manipulations, string processing, and basic mathematical logic (e.g., loops, conditional statements).
This article provides an in-depth look at the , breaking down the exam pattern, the most frequently asked problems from the April and September drives, and providing logical solutions in C, C++, and Python. 1. TCS Coding Pattern 2021: Ninja vs. Digital A JAR has capacity N
Input: "aabbccdde" → Output: "abcde" . Two-pointer or stack.
The most efficient approach is to store the keywords in a hash-based set or a fixed array. Since the dataset is static and small, a standard lookup achieves time complexity. Python 3 Implementation
Here are some recommended books and resources to help you prepare for the TCS coding test: Given input (candies ordered), display the number of
Logic: Write an isPrime() function and a digitSum() function.
Wrong Data Types: Using int instead of long long in C++ for large factorial or power results.