As reported: Confluent SSE2 phone screen (May 2025): given a list of function signatures and a list of input argument types, return all functions that match based on parameter compatibility. Follow-up: handle variadic arguments such as
Integer... args. The focus was type matching and signature parsing.
Implement FunctionLibrary:
FunctionLibrary(functions)— each function has aname, an ordered list of parameter typesparamTypes, and a flagisVariadic.findMatches(argTypes)— the names of all functions that accept a call with arguments of typesargTypes(in order), sorted alphabetically.
Matching rules:
- A non-variadic function matches when
argTypesequalsparamTypesexactly (same length, same type at every position). - A variadic function (at least one parameter) treats its last parameter type as repeatable: it matches when the arguments are its first
k − 1parameter types followed by one or more arguments of the last parameter's type.
Types match only when equal — no conversions or subtyping.
Example
FuncA (String, Integer, Integer)
FuncB (String, Integer...) variadic
FuncC (Integer...) variadic
FuncD (Integer, Integer)
FuncE (Integer, Integer, Integer)
FuncF (String)
FuncG (Integer)
findMatches(["String"]) -> ["FuncF"]
findMatches(["Integer"]) -> ["FuncC", "FuncG"]
findMatches(["Integer", "Integer", "Integer", "Integer"]) -> ["FuncC"]
findMatches(["String", "Integer", "Integer"]) -> ["FuncA", "FuncB"]
findMatches(["String", "Integer", "Integer", "Integer"]) -> ["FuncB"]
findMatches([]) -> []
Constraints: up to 2,000 functions with up to 8 parameters; up to 2,000 queries with up to 12 argument types; function names are unique.
Code runner format: two JSON values, one per line: the functions as [name, paramTypes, isVariadic] triples, and the list of queries. The runner builds one FunctionLibrary (Java/C++/Go/JS receive Function objects with name, paramTypes, isVariadic; Python receives tuples) and prints findMatches for every query.