Card Metadata
Card Range Obfuscation
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 with 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, defined by a start and end.
In this problem, we’ll be taking as input a 6-digit BIN, along with N intervals within the BIN range corresponding to brands. We’ll return a list of sorted intervals covering the entire BIN range (i.e. for a BIN of 424242, covering 4242420000000000 to 4242429999999999), inclusive.
Input format
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.
Example:
777777
2
1000000000,3999999999,VISA
4000000000,5999999999,MASTERCARD
Output format
Your output will consist of one or more lines containing the resulting intervals and their corresponding brands. The output intervals should be sorted by start.
Example:
7777770000000000,7777773999999999,VISA
7777774000000000,7777775999999999,MASTERCARD
Part 4
For the fourth set of testcases, adjacent intervals (i.e. intervals with no gaps in between) with the same brand after extending should be merged into one interval in the output. This will be sufficient to solve the next 3 testcases.
Example 1: the two adjacent VISA intervals were merged
Input:
424242
2
0000000000,5999999999,VISA
6000000000,9999999999,VISA
Output:
4242420000000000,4242429999999999,VISA
Example 2: the VISA intervals were extended to fill the gaps, then merged
Input:
424242
2
0000000000,3999999999,VISA
6000000000,9999999999,MASTERCARD
Output:
4242420000000000,4242425999999999,VISA
4242426000000000,4242429999999999,MASTERCARD
我们长期稳定承接各大科技公司如TikTok、Google、Amazon等的OA笔试代写服务,确保满分通过。如有需求,请随时联系我们。
We consistently provide professional online assessment services for major tech companies like TikTok, Google, and Amazon, guaranteeing perfect scores. Feel free to contact us if you're interested.
