Payment card numbers are composed of eight to nineteen digits, the leading six of which are referred to as the bank identification number (BIN). Stripe's card metadata API exposes information about different card brands within each BIN range by returning a mapping of card intervals to brands.
However, a given BIN range may have gaps at the beginning, middle, or end of the range where no valid cards are present. This information can be used by fraudsters to test for valid credit cards with a high degree of probability. To prevent fraudsters from abusing the data gaps, we must fill in missing values by extending the returned intervals to cover the entire range.
A BIN range refers to all the 16-digit card numbers starting with a given BIN; for example, a BIN of 424242 has a range of 4242420000000000 to 4242429999999999, inclusive.
An interval is a subset of a BIN range, also inclusive.
The problem states: We'll be taking as input a 6-digit BIN and a list of 10-digit intervals within the BIN range corresponding to brands. We'll return a list of sorted intervals covering the entire BIN range (e.g., for a BIN of 424242, covering 4242420000000000 to 4242429999999999, inclusive).
Your input will consist of one line containing a six-digit BIN, one line containing a positive integer N, and N lines containing intervals and their corresponding brands.
The format of each interval is start, end, brand, where start and end are the 10 digits following the input BIN and brand is an alphanumeric string.
Return a list of sorted intervals covering the entire BIN range, including the previously missing gaps.