Tcs Coding Questions 2021 ❲2024❳
TCS loved problems that mix string indexing and array frequency. Question 4: "Minimum Coins" (Greedy Algorithm – Modified) Problem Statement: 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.
Introduction: The Gatekeeper of an IT Dream Tcs Coding Questions 2021
Input: [11, 23, 41, 29, 56] Output: 3 (Because 11→1+1=2(prime), 23→2+3=5(prime), 41→4+1=5(prime), 29 is prime but 2+9=11(prime) actually also qualifies—so 4? Wait: 56 is not prime. So output is 4). TCS loved problems that mix string indexing and
Input: "WWWNWWWNW" Output: "FNWFNW" (first three W→F, then single N, then next three W→F, then N, then single W). But with a twist: You cannot use the