A teacher writes a sentence. She wants to reverse the words that have an even length, but leave odd-length words unchanged. Print the final sentence. Example: Input: "Hello World Python" → Output: "olleH World nohtyP"
Don't just read the solutions. Open your IDE right now, type them out, run test cases, break them, and fix them. That muscle memory will save you on exam day. Tcs Coding Questions 2021
By mastering these 5+ patterns, you will solve 80% of TCS NQT coding problems. The remaining 20% is about speed, accuracy, and handling edge cases. A teacher writes a sentence
M = 18. Standard greedy uses 10+5+3 = 3 coins. But 18-10=8, and 8 is not divisible by 3, so allowed. If M=20, standard: 10+10 =2 coins, but after first 10, remainder=10 (not divisible by 3) → allowed. If M=15, standard: 10+5=2 coins, but remainder after 10 is 5 (not div by 3) → allowed. Actually this twist made it tricky. Example: Input: "Hello World Python" → Output: "olleH
import java.util.Scanner; 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];
Wait—The actual TCS 2021 version was simpler: Replace all non-overlapping "WWW" with "F". But overlapping should remain.