Depth-First Search (DFS)
Although it is an easy problem and likely there is a clever way to solve it using just mathematical tricks, I decided to do a full implementation of Depth-First Search (DFS). Notice that the "visited" requires you to also use the cardinality of the number of steps taken. Code is down below, cheers, ACC. Even Number of Knight Moves - LeetCode You are given two integer arrays start and target , where each array is of the form [x, y] representing a cell on a standard 8 x 8 chessboard. Return true if a knight can move from start to target in an even number of moves. Otherwise, return false . Note: A valid knight move consists of moving two squares in one direction and one square perpendicular to it. The figure below illustrates all eight possible moves from a cell. Example 1: Input: start = [1,1], target = [2,2] Output: true Explanation: One possible sequence of moves is (1, 1) -> (3, 2) -> (2, 4) -> (4, 3) -> (2, 2) . The knight reaches the target in 4 mov...