Level: Senior-Level
Round: Phone Screen · Type: Coding · Difficulty: 5/10 · Duration: 60 min · Interviewer: Neutral
Topics: Data Structures, Algorithms, Function Overloading
Location: San Francisco Bay Area
Interview date: 2025-12-07
Got offer: False
I had a phone screen where I was asked to design a registry system for function overloads, similar to C++/Python dispatch. The functions have a name, argument type list, and possibly isVariadic. I needed to implement register() to store the functions and find_matches() to return all functions whose argument signatures match (or can match via variadic args).
The coding question was:
` register([ funA: {["Boolean", "Integer"]}, funB: {["Integer"]}, funC: {["Integer"]} ])
find_matches(["Boolean", "Integer"]) -> [funA] find_matches(["Integer"]) -> [funB, funC] `
` class Function(object): def init(self, name, argument_types): self.name = name self.argument_types = argument_types
def __repr__(self):
return f"Function<{self.name}>"
class FunctionLibrary(object): def init(self): pass # TODO
def register(self, list_of_functions):
pass # TODO
def find_matches(self, argument_types):
pass # TODO
flib = FunctionLibrary() flib.register([ Function("funA", ["Boolean", "Integer"]), Function("funB", ["Integer"]), Function("funC", ["Integer"]) ])
assert flib.find_matches(["Boolean", "Integer"]) == ["funA"] assert flib.find_matches(["Integer"]) == ["funB", "funC"] `
isVariadic support)` """ register([ funA: {["Boolean", "Integer"], isVariadic: False}, funB: {["Integer"], isVariadic: False}, funC: {["Integer"], isVariadic: True} ])
findMatches(["Boolean", "Integer"]) -> [funA] findMatches(["Integer"]) -> [funB, funC] findMatches(["Integer", "Integer", "Integer"]) -> [funC] """
class Function(object): def init(self, name, argument_types, is_variadic): self.name = name self.argument_types = argument_types self.is_variadic = is_variadic
def __repr__(self):
return "Function<{}>".format(self.name)
class FunctionLibrary(object): def init(self): pass # TODO
def register(self, list_of_functions):
pass # TODO
def find_matches(self, argument_types):
pass # TODO
`
I was asked to design a registry system for function overloads (similar to C++/Python dispatch).
isVariadic.register() to store them.find_matches() to return all functions whose argument signatures match (or can match via variadic args).