Identify Broken Customer Transactions
Updated
Problem statement
A payment pipeline records the customer name for every transaction it starts in initiatedCustomers and for every transaction it finishes in completedCustomers.
A customer is broken when the number of initiated records for that name differs from the number of completed records. Return every broken customer name exactly once, in lexicographic order.
Names are matched exactly and are case-sensitive. A name that appears in only one array is broken.
Function
findBrokenCustomers(initiatedCustomers: String[], completedCustomers: String[]) → String[]Examples
Example 1
initiatedCustomers = ["Ada","Bo","Ada","Cy"]completedCustomers = ["Ada","Bo","Cy"]return = ["Ada"]Ada has two initiated records but only one completed record, so Ada is broken. Bo and Cy each have the same number of initiated and completed records.
Example 2
initiatedCustomers = ["Mia","Noah","Mia"]completedCustomers = ["Noah","Mia","Liam"]return = ["Liam","Mia"]Mia has two initiated records and one completed record, so Mia is broken. Noah matches. Liam only appears in the completed list, so Liam is broken. In sorted order the answer is Liam, then Mia.
Constraints
0 ≤ initiatedCustomers.length ≤ 1000000 ≤ completedCustomers.length ≤ 100000- Each name has between 1 and 50 ASCII letters.
- The two arrays together hold at most 2000000 characters.
More Yelp interview questions
Similar questions at other companies
- Majority ElementByteDance · PHONE SCREENByteDance interview questions
- Recommend Films from Viewers Who Watched Everything You DidBloomberg LP · PHONE SCREENBloomberg LP interview questions
- Shared Courses for Every Pair of StudentsCrunchyroll · PHONE SCREENCrunchyroll interview questions
- Employee Count Median, Mean and ModeClay · PHONE SCREEN
- Convert an Entry List to a MapEPAM · PHONE SCREENEPAM interview questions
- Values Exclusive to the Current UserMeta · PHONE SCREENMeta interview questions
- Count Values Appearing Exactly OnceAgoda · PHONE SCREENAgoda interview questions
- Top Two Users by Total Purchase AmountSnowflake · PHONE SCREENSnowflake interview questions
- Restaurant Vote LeadersZipRecruiter · PHONE SCREEN · ONSITE INTERVIEWZipRecruiter interview questions
- AI Role: Collection with Add and Remove OperationsApple · PHONE SCREENApple interview questions