Tcs Coding Questions 2021 -
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.
Wait – clarify: Better example: arr = [1, 2, 3, 4, 3], K = 6 Pairs: (2,4) and (3,3) → 2 pairs.
Example N=4:
6