Code for the Solution: https://codeforces.com/contest/1761/s...
Trying codeforces after long time. Will take some time to get back in the game :D
Problem was quite interesting. do let me know how you solved it and in case you have a better solution for it.
Thanks for watching, do like and subscribe!