NUMBER OF CANDIES SOLD: 3 , NUMBER OF CANDIES AVAILABLE: 7 Input: N=10, k=5, order=0 Output: INVALID INPUT Python Solution:
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.
For those preparing for TCS recruitment, the 2021 coding assessments (NQT, Ninja, and Digital) centered on core programming logic, array manipulations, and mathematical series. Succeeding in these rounds requires a strong grasp of standard input/output (STDIN/STDOUT) and basic data structures GitHub Pages documentation Core Coding Topics from 2021 Tcs Coding Questions 2021
def count_pairs(arr, target): count = 0 for i in range(len(arr)): for j in range(i+1, len(arr)): if arr[i] + arr[j] == target: count += 1 return count
TCS 2021 questions largely focused on these algorithms. Master these patterns, and you can solve almost any variation: NUMBER OF CANDIES SOLD: 3 , NUMBER OF
Many lost marks by using replace() in Python without controlling overlap.
: 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". Succeeding in these rounds requires a strong grasp
You might ask: "Why study 2021 questions if the exam is in 2025/2026?" Here is the truth about TCS:
Let's walk through a classic TCS coding question from the "Candy Jar" problem to see this strategy in action.
Succeeding in the TCS NQT coding section requires more than just understanding syntax; it demands speed, edge-case management, and familiarity with the assessment console. 1. Master Input/Output Operations
TCS Coding Questions 2021: Top Problems and Preparation Guide