OpenAI·Software Engineer·Technical Phone Screen
- You have a Node class representing types in a small toy language. Nodes can be primitives (char, int, float), generic placeholders (T1, T2, etc.), or tuples of other Nodes. Implement an infer_return(input_type, actual_type) function that walks both type trees simultaneously, records what concrete types each generic maps to, raises an error on conflicting bindings or structural mismatches, and returns the final generic-to-type mapping. Then discuss how you'd extend this to nested generics and use the result to resolve a return type.
“I started okay, got the basic tree walk going and handled the primitive case fine.”