Given q link soln in cpp(ps i have watch gfg article for the same but not passing all test case)

https://hack.codingblocks.com/app/dcb/1599

I mentioned the code which will pass all the test case not a reffernce type one , ps if u cant ans then leave no need to ans wrong or similar code