Groq interview question

DFS based to create input and output nodes