Minimum Unique Card Suffix Length
Problem statement
Each distinct nonnegative integer in cardNumbers is a bank-card number. Return the smallest positive integer k such that the last k decimal digits of every card number are unique across the array.
The last k digits of a number are its remainder modulo 10^k. If a number has fewer than k digits, its suffix value is the entire number. Because all card numbers are distinct and fit in at most 16 decimal digits, a valid k always exists.
Function
minimumUniqueSuffixLength(cardNumbers: long[]) → intExamples
Example 1
cardNumbers = [1111111111111234,2222222222221224,3333333333331235]return = 2One digit gives 4, 4, 5, so the first two cards collide. Two digits give 34, 24, 35, which are all unique.
Example 2
cardNumbers = [10,20,30]return = 2All one-digit suffixes are 0. The two-digit suffixes are 10, 20, 30.
Example 3
cardNumbers = [101,202,303]return = 1The one-digit suffixes 1, 2, 3 are already distinct.
Constraints
1 <= cardNumbers.length <= 100000.0 <= cardNumbers[i] <= 9000000000000000.- All values in
cardNumbersare distinct.