Select Compatible Card Applications
Problem statement
A payment card advertises application identifiers in preference order, and a terminal supports its own set of application identifiers.
Return the identifiers advertised by the card that the terminal also supports. Preserve the card's original order. Matching is exact and case-sensitive.
Function
selectCompatibleApplications(cardApplications: String[], terminalApplications: String[]) → String[]Examples
Example 1
cardApplications = ["A0000000031010","A0000000041010","A00000002501"]terminalApplications = ["A0000000041010","A0000000031010"]return = ["A0000000031010","A0000000041010"]Both Visa and Mastercard identifiers are supported, and the card's preference order is retained.
Example 2
cardApplications = ["app.pay","app.rewards","app.credit"]terminalApplications = ["app.credit","app.pay"]return = ["app.pay","app.credit"]app.rewards is not supported. The remaining identifiers follow card order, not terminal order.
Example 3
cardApplications = ["A","B"]terminalApplications = ["a","C"]return = []Matching is case-sensitive, so A does not match a.
Constraints
0 <= cardApplications.length, terminalApplications.length <= 100000.- Each array contains unique non-empty identifiers.
- Every identifier has length at most
200. - Matching is exact and case-sensitive.