I am not sure how to take the input of the problem as there is no mention of the total number of elements. So how am I supposed to know when will the loop stop?
Please provide the solution
hi @astha119btcse21_7380491a239a3b9b,
it is similar to the bfs u do check here ive commented where the change is https://ide.codingblocks.com/s/658921 do a dry run once for better understanding