If my approach is wrong, suggest something else. Link to my code : https://ide.codingblocks.com/s/221534
@O17LPOLA020011 refer to this code