I got the hint that this question will be solved by BFS somehow. but still I am unable to think of how it will be. If I follow the recursive approach for it,it gives TLE. the time constraints are enough as there are 10s for each input where 5 test cases get 50s while one of my friends solved it in just 22s.
here is the link to the question’s screenshot as it is a private practice session ,so it cannot be accessed by everybody.But,only question and constraints are required to solve the problem .so here is it’s google drive link :-
https://drive.google.com/drive/folders/1eTpqXzns6kaeOgD0ZRP1QzXE-1tVyhrx?usp=sharing
you may upload the solution there or may reply me here.
Thank You for the help :).
max time for c++ code is 50s
for python it’s 250s.
for java it’s 200s.
I would be happy to have the solution in any of the above languages.