Sponsored
Use these hints if you're stuck. Try solving on your own first.
Use BFS to find the answer.
The state of the BFS is the position (x, y) along with a binary value that specifies if the position is horizontal or vertical.
Solve with full IDE support and test cases