×

Tcs Coding Questions 2021 -

M=13. Standard greedy: 10+3 = 2 coins. But remainder after 10 =3 (divisible by 3) → forbidden. So you must choose 5+5+3 =3 coins.

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

Input: "1100111001" Output: 3 (groups: "11", "111", "1") So you must choose 5+5+3 =3 coins

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). That muscle memory will save you on exam day

"1001" → Choose substring indices 1 to 3 ("001")? Actually original: 1 0 0 1. Pick substring positions 2-4 (0,0,1) has only one '1'. Not allowed. This was so tricky that TCS 2021 actually had a simpler version: Count the number of groups of consecutive '1's.