Link to the question:- https://www.interviewbit.com/problems/rook-movement/
I tried BFS where in each state I store min steps,direction (up,down,left or right). I am getting TLE for large inputs.
Can someone help me ?
code:- https://pastebin.com/zNJmwqCA
Thanks.