Amdocs Interview Question

String traversal using bfs and dfs