Tcs Coding Questions 2021 [FHD]

is valid (i.e., candy is available and ordering it doesn't break rules illegally), output the number of candies sold and the remaining candies. If the input is invalid, print "INVALID INPUT". (Standard default values used in 2021 test cases). Check if the ordered candies is greater than 0 and less than or equal to If valid, candies sold = . Remaining candies = If remaining candies ≤Kis less than or equal to cap K , the jar is automatically refilled back to Python Code:

Are you targeting the (standard) or Digital (advanced) role track? Share public link

TCS exams, including the 2021 NQT, consist of a mix of Easy, Medium, and sometimes Advanced level coding questions 0.5.3. Generally 1 or 2 coding problems.

for (char ch : num.toCharArray()) freq[ch - '0']++; Tcs Coding Questions 2021

The TCS NQT for the 2021 batch was a challenging but conquerable test. The coding questions were not about writing complex algorithms but about demonstrating .

Subarrays, rotating arrays, finding leaders in an array, matrix rotations, and two-pointer techniques.

Ensure your code handles zero inputs, negative values, empty strings, and exceedingly large integer sizes. Use long long in C++ and long in Java when computing deep factorials or large products. is valid (i

public class Main public static void main(String[] args) Scanner sc = new Scanner(System.in); String num = sc.next(); int len = num.length(); int[] freq = new int[10];

: There is a jar of candies with a total capacity N=10 . It must never be refilled until it reaches K=5 or fewer candies. A customer can order a certain number of candies. Write a program to process the order, update the jar, and display the result. If the order is invalid (0 or negative), print "INVALID INPUT".

Below are three highly representative coding questions that appeared across various campus slots in 2021, complete with clean Python and C++ implementations. Problem 1: The Sweet Seventeen (Number Base Conversion) Check if the ordered candies is greater than

Find an index such that the sum of elements at lower indices equals the sum of elements at higher indices.

Geared towards advanced roles (with a significantly higher salary package), focusing on advanced data structures, dynamic programming, greedy algorithms, and complex mathematical logic. Exam Structure and Rules Languages Allowed: C, C++, Java, Python, and Perl.

By systematically preparing the topics outlined in this guide and practicing the coding questions provided, you will build the confidence and skill to succeed. Remember, companies like TCS value problem-solving ability as much as syntax. Good luck with your preparation