Please check the code question link :- https://hack.codingblocks.com/app/contests/1483/1103/problem
check out this code