Description
Solutions
Card Range Obfuscation Part1 (ML Eng :)
πŸ”₯ FULLTIME

🐝 Hi there! The description you are currently reading is just 1st part of the problem set. It is highly recommended to read ALL THE PARTS before coding as parts may build on top of each other 🐳

  • Card Range Obfuscation Part 1 (ML Eng :) πŸ¦”
  • Card Range Obfuscation Part 2 (ML Eng :) 🐹
  • Card Range Obfuscation Part 3 (ML Eng :) 🦚
  • Card Range Obfuscation Part 4 (ML Eng :) πŸ₯
  • 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 info 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 info can be used by fraudsters 😞 to test for valid credit cards within 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 (p.s. too many zeros, if you find anything wrong, pls lmk! Many thanks in advance :) to 4242429999999999 (p.s. too many 9s; my eyes are blind.. if you find anything wrong, pls lmk! Many thanks in advance :)

    An interval is a subset of a BIN range, also inclusive.

    In this problem, we will be taking as input as 6-digit BIN and a list of 10-digit intervals within the BIN range corresponding to brands. We will 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 10 digits following the input BIN and branch is an alphanumeric string.

    Example:

    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

    Part 1

    For the first set of testcases, you will be given a set of non-overlapping intervals with gaps on the lower end and/or higher end of the BIN range. You are expected to extend the lowest interval to the lower boundary of the BIN range, and the highest to the higher boundary of the BIN range. This will be sufficient to solve the first 4 test cases.

    Example 1:

    Input:  BIN = 424242, N = 1, info = [["5000000000", "6555555555", "VISA"]]
    Output: [["4242420000000000", "4242429999999999", "VISA"]]
    Explanation:
    Example 1: the VISA interval was extended on the lower and higher ends to cover the BIN range. Note - I double checked the input & output numbers while uploading, but since there are so many digits, I might count them wrong. If you notice anything wrong, pls feel free to lmk. I am more than happy to modify accordingly. Many thanks in advance! You da best!!

    Example 2:

    Input:  BIN = 424242, N = 2, info = [["4000000000", "8999999999", "MASTERCARD"], ["1000000000", "3999999999", "VISA"]]
    Output: [["4242420000000000", "4242423999999999", "VISA"], ["4242424000000000", "424242429999999999", "MASTERCARD"]]
    Explanation:
    Example 2: the VISA interval was extended on the lower end and the Mastercard interval was extended on the higher end. Note - I double checked the input & output numbers while uploading, but since there are so many digits, I might count them wrong. If you notice anything wrong, pls feel free to lmk. I am more than happy to modify accordingly. Many thanks in advance! You da best!!
    Constraints:
      🫢
    Thumbnail 0
    Testcase

    Result
    Case 1

    input:

    output: