All tests pass (moved visited[adjacent] = true logic to a more specific place