AI DFS & BFS Solution