Minimum Unique Card Suffix Length
Updated
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.
More Bloomberg LP Onsite Interview questions
- Collatz Conjecture with Shared MemoizationPHONE SCREEN · ONSITE INTERVIEW · Seen Nov 2026
- Word SearchOA · PHONE SCREEN · ONSITE INTERVIEW · Seen Nov 2026
- N-ary Index-Path Encoder and DecoderPHONE SCREEN · ONSITE INTERVIEW · Seen Nov 2026
- Top K Frequent WordsONSITE INTERVIEW · Seen Nov 2026
- Trapping Rain WaterPHONE SCREEN · ONSITE INTERVIEW · Seen Nov 2026
- Design Browser HistoryPHONE SCREEN · ONSITE INTERVIEW · Seen Oct 2026
- Mutable Stock Price Top KPHONE SCREEN · ONSITE INTERVIEW · Seen Oct 2026
- Add Two Numbers IIPHONE SCREEN · ONSITE INTERVIEW · Seen Oct 2026
- Decode StringPHONE SCREEN · ONSITE INTERVIEW · Seen Oct 2026
- Minimum Replacements to Make Two Strings AnagramsPHONE SCREEN · ONSITE INTERVIEW · Seen Sep 2026
Similar questions at other companies
- Group-Relative Policy AdvantagesAmazon · ONSITE INTERVIEW
- Product Total With the Cheapest PromotionInstacart · ONSITE INTERVIEWInstacart interview questions
- Equation Tuple CombinationZoox · ONSITE INTERVIEW
- Unique Near-Equal Target-Sum PairsFivetran · ONSITE INTERVIEWFivetran interview questions
- Count Pairs Divisible by KApple · ONSITE INTERVIEWApple interview questions
- Digit-Reversed Pairs in an ArrayExpedia · ONSITE INTERVIEWExpedia interview questions
- Max Points on a LineLinkedIn · ONSITE INTERVIEWLinkedIn interview questions
- Majority ElementMicrosoft · ONSITE INTERVIEWMicrosoft interview questions
- Count Index Pairs with Equal Value OffsetGoogle · ONSITE INTERVIEWGoogle interview questions
- Net Position Calculation from API SnapshotsHeadlands Technologies · ONSITE INTERVIEWHeadlands Technologies interview questions
Bloomberg LP interview experiences
- Bloomberg AI-Assisted Coding Round, All Levels: 14 Experiences
- Bloomberg SWE Intern Interview Questions: 68 Questions
- Bloomberg Interview Questions, Level Not Reported: 65 Questions
- Bloomberg Experienced Design & More: 126 Questions (Part 2 of 2)
- Bloomberg Experienced SWE Interviews: 167 Questions (Part 1 of 2)
- Bloomberg New Grad Coding Questions: 121 Questions (Part 2 of 2)