https://ide.codingblocks.com/s/330382 in comments shown logic
@pranjuldwivedi120568 Your code is extremely confusing. Can you break it down ?