Tcs Coding Questions 2021 -
public static void main(String[] args) String str = "abca"; System.out.println(validPalindrome(str) ? "Yes" : "No");
To prepare effectively for questions like those seen in 2021:
In a foreign country, the currency denominations are [1, 3, 5, 10, 25, 50] . Given an amount M (≤ 1000), find the minimum number of coins needed. But with a twist: You cannot use the 10-rupee coin if the remaining amount after using other coins is divisible by 3.
Functions like malloc() , calloc() , and free() .
return 0;
In a cricket match, the captain maintains a string of 'W' (wicket) and 'N' (normal ball). A bowler is said to have "fever" if he takes 3 consecutive wickets (i.e., "WWW"). Given a string, replace every such occurrence of "WWW" with "F" (fever) and print the modified string. However, if two fever patterns overlap (like "WWWW" -> contains two overlapping "WWW" starting at index 0 and 1), count it only once.
If the average oxygen level of a trainee is below 70, they are unfit.
Odd positions: powers of 2 → 2^(0), 2^(1), 2^(2)... Even positions: powers of 3 → 3^(1), 3^(2), 3^(3)...
To tackle the coding questions, it's crucial to first understand the structure of the TCS NQT exam in 2021. The exam typically consisted of several sections, with the coding component playing a decisive role. Tcs Coding Questions 2021
Always write conditional blocks to handle null values, negative array bounds, and invalid data constraints.
private static boolean isPalindrome(String s, int left, int right) while (left < right) if (s.charAt(left) != s.charAt(right)) return false; left++; right--;
Based on memory-based results from the September 2021 drive, here are some of the most frequently reported coding questions: A. Number Problems & Digital Logic
Brush up on modular arithmetic, matrix operations, factorials, and base conversions. public static void main(String[] args) String str =
return ans;
If you would like to see like dynamic programming or matrix conversions. Share public link
TCS NQT Foundation (Slot 1, 2, 3 – March 2021)
Tests nested function calls and primality checking within constraints (n ≤ 10^6). But with a twist: You cannot use the