Qualcomm interview question

stack and head consturct bfs dfs