Digit-Coded Card Validation
Learn this problemProblem statement
You are given three parallel arrays describing digit-coded payments: cardNumbers, transactionIds, and integer-dollar amounts. Return one validity flag per payment in input order.
Indices are zero-based from the left. In each 16-digit card number, index 13 is 1 for multi-use and 0 for one-time, index 14 is 0 for Visa and 1 for Master, and index 15 is 1 for merchant-bound and 0 for unbound. In each 8-digit transaction ID, index 6 is 1 for charge and 0 for authorization, while index 7 is 1 for online and 0 for offline.
A Visa payment is valid when the card is merchant-bound and multi-use, or when the transaction is an online charge below 100. A Master payment is valid when an unbound card has amount below 100, or when a merchant-bound card has amount above 100. These comparisons are strict, so amount 100 satisfies neither amount rule.
Function
validatePayments(cardNumbers: String[], transactionIds: String[], amounts: int[]) → boolean[]Examples
Example 1
cardNumbers = ["1234567891011111"]transactionIds = ["50781100"]amounts = [150]return = [true]The card's final three flags are 111: multi-use, Master, and merchant-bound. A merchant-bound Master payment above 100 is valid.
Example 2
cardNumbers = ["1234567890123101","1234567890123000","1234567890123010","1234567890123011"]transactionIds = ["12345600","12345611","12345600","12345611"]amounts = [500,99,99,100]return = [true,true,true,false]The first Visa card is merchant-bound and multi-use. The second is an online Visa charge below 100. The third is an unbound Master payment below 100. The last is merchant-bound Master at exactly 100, which matches neither strict amount rule.
Example 3
cardNumbers = ["1234567890123000"]transactionIds = ["12345601"]amounts = [50]return = [false]This is an online Visa authorization, not a charge, and the card is neither merchant-bound nor multi-use.
Constraints
1 <= cardNumbers.length = transactionIds.length = amounts.length <= 100000.- Every card number contains exactly
16decimal digits, and every transaction ID contains exactly8decimal digits. - Each encoded flag at card indices
13,14, and15and transaction indices6and7is either0or1. 1 <= amounts[i] <= 1000000000.