In one of the coding rounds, I was asked to solve an accounting-related problem for an event ticketing system.
The problem was about matching payments from a payment gateway with users who bought tickets. At the end of the day, all received payments needed to be matched back to the corresponding users. The interviewer mentioned that there would always be a 1-to-1 match between users and payments.
The task was to write a function that, given the user data, pricing data, and payment data, returns a data structure that maps each user’s name to their corresponding payment ID.
Interview Details
Problem Setup
Each user record included information like:
Name
Email
Ticket type purchased
Quantity
The payment gateway data included:
Payment ID
Email
Payment amount
The matching rules were:
First, try to match a payment to a user by email.
If the email does not match, then use the payment amount to infer the correct user.
For each payment amount, there would be at most one payment that could not be matched by email.
User names were guaranteed to be unique.
Example
The user table looked roughly like this:
Name Email Purchase Quantity
John A. john.a@mail.com Top 3
James S. j.s@mail.com Economy 2
Stacy C. stacy.c@test.com Economy 2
Bobby B. bob@mail.com Medium 10
Michelle X. mix@test.com Medium 10
Linda F. l.f@mail.com Top 10
Betty T. b.t@mail.com ThreeEco 1
Nancy L. n.l@test.com TwoEco 1
Daniel
Name Email Purchase Quantity
John A. john.a@mail.com Top 3
James S. j.s@mail.com Economy 2
Stacy C. stacy.c@test.com Economy 2
Bobby B. bob@mail.com Medium 10
Michelle X. mix@test.com Medium 10
Linda F. l.f@mail.com Top 10
Betty T. b.t@mail.com ThreeEco 1
Nancy L. n.l@test.com TwoEco 1
Daniel
Unlock Full Details
Create a free account to unlock this interview experience report.