FastPrepVariadic Function Library Matches
Problems/Variadic Function Library Matches

Variadic Function Library Matches

IBM logoIBM● MediumFULLTIMEPHONE SCREEN
QuestionFunctionExamplesConstraints

Problem statement

Source note: The interview report defines a registered function library and explicitly states that a variadic final type may consume zero or more arguments. The finite batch returns all compatible registrations without adding type coercion rules.

A function library registers functions in order. Function i has name names[i], declared parameter types parameterTypes[i], and flag isVariadic[i].

A non-variadic function matches a query only when its declared types equal the query exactly. A variadic declaration must be non-empty: every declared type before the last is a fixed prefix, and the final declared type accepts zero or more query arguments. Type tokens compare by exact case-sensitive equality.

Return the names of every matching function in registration order.

Function

findFunctionMatches(names: String[], parameterTypes: String[][], isVariadic: boolean[], queryTypes: String[]) → String[]

Examples

Example 1

names = ["foo","bar","baz"]parameterTypes = [["String"],["String","Integer"],["String","Integer"]]isVariadic = [false,true,false]queryTypes = ["String"]return = ["foo","bar"]

The variadic final Integer consumes zero arguments, while the fixed two-parameter function does not match.

Example 2

names = ["join","pair"]parameterTypes = [["String","String"],["String","String"]]isVariadic = [true,false]queryTypes = ["String","String","String"]return = ["join"]

The final type of join repeats to consume both trailing arguments.

Example 3

names = ["sum"]parameterTypes = [["Integer"]]isVariadic = [true]queryTypes = []return = ["sum"]

A declaration consisting only of its variadic type accepts an empty query.

Constraints

  • names.length == parameterTypes.length == isVariadic.length.
  • 0 <= names.length <= 100000.
  • The total number of declared and query type tokens is at most 300000.
  • Names and type tokens are non-empty ASCII strings of length at most 100.
  • Every variadic declaration contains at least one type.

More IBM problems

  • Count Strictly Increasing Contiguous WindowsOA · Seen Nov 2026
  • Total Each Letter's Count in an Encoded StringOA · Seen Nov 2026
  • Count Servers With No Requests in a Time WindowOA · Seen Nov 2026
All IBM interview questionsSee IBM hiring insights
Saved
class Solution {
    public String[] findFunctionMatches(String[] names, String[][] parameterTypes, boolean[] isVariadic, String[] queryTypes) {
        // Write your solution here.
    }
}
Checking account…