Mutual Wishlist Rankings
Updated
Problem statement
Users of an apartment-exchange service keep ordered wishlists of other users' apartments.
Each wishlist row is user:choice1,choice2,..., with rank 0 as the first choice. Process two kinds of operations:
MUTUAL user rank: returntruewhen the apartment at that rank belongs to another user who also placesuserat the same rank.CHANGED user rank:rankis at least1. Imagine moving that entry up one position by swapping ranksrankandrank-1. Without mutating the stored wishlist, return the users whose mutual-ranked status withuserwould change.
Return one string per operation. A changed list is formatted as sorted usernames inside brackets, for example [a,c] or [].
Function
evaluateWishlist(wishlists: String[], operations: String[]) → String[]Examples
Example 1
wishlists = ["a:c,d","b:d,a,c","c:a,b","d:c,a,b"]operations = ["MUTUAL a 0","MUTUAL b 0","MUTUAL a 1","CHANGED d 1","CHANGED b 2","CHANGED b 1"]return = ["true","false","true","[a]","[c]","[]"]a/c are mutual first choices, a/d are mutual second choices, and only the source-described pairings change under each hypothetical rank bump.
Example 2
wishlists = ["amy:bo,cy","bo:cy,amy","cy:amy,bo"]operations = ["MUTUAL amy 0","MUTUAL amy 1","CHANGED amy 1"]return = ["false","false","[bo,cy]"]Neither original rank is mutual. Swapping amy's choices creates mutual rank 0 with cy and mutual rank 1 with bo.
Constraints
1 <= wishlists.length <= 1000.- Usernames are unique, and every listed choice names another supplied user at most once.
1 <= operations.length <= 10000.- A
MUTUALrank may be out of range and then returnsfalse. - A
CHANGEDrank is valid and at least1. - Operations do not mutate the wishlists.
More Stripe Phone Screen questions
- Financial Account LedgerOA · PHONE SCREEN · Seen Nov 2026
- Business Account KYC Verification — Parts 1–5PHONE SCREEN · Seen Nov 2026
- Merchant Matching, Parts 1–2: Shared Fields and Weighted ThresholdsPHONE SCREEN · Seen Nov 2026
- Parse Boolean Rule ExpressionsPHONE SCREEN · ONSITE INTERVIEW · Seen Nov 2026
- Merchant Payout Scheduler, Part 2: Per-Merchant SchedulesPHONE SCREEN · Seen Nov 2026
- Transaction Fee Calculator — Parts 1–2: Basic Fee Calculation and Conditional Fee RulesPHONE SCREEN · Seen Nov 2026
- Render a Task Tree from CSV RowsPHONE SCREEN · ONSITE INTERVIEW · Seen Nov 2026
- Invoice / Payment ReconciliationPHONE SCREEN · ONSITE INTERVIEW · Seen Nov 2026
- Linked Merchants Within Two HopsPHONE SCREEN · Seen Nov 2026
- Portfolio Valuation, Part 1PHONE SCREEN · Seen Nov 2026
Similar questions at other companies
- Logger Rate Limiter with Every-Arrival HistoryGoogle · PHONE SCREENGoogle interview questions
- Propagating Fraud DetectorAffirm · PHONE SCREEN · ONSITE INTERVIEWAffirm interview questions
- Order and Batch Open-Close LifecycleHudson River Trading · PHONE SCREENHudson River Trading interview questions
- Pins Violation Log QueriesPinterest · PHONE SCREENPinterest interview questions
- Resource Reconciler: Plan and Apply CreatesPerplexity AI · PHONE SCREENPerplexity AI interview questions
- Realized Gains from a Real-Estate Transaction StreamKikoff · PHONE SCREENKikoff interview questions
- Process On-Call Routing OperationsOpenAI · PHONE SCREENOpenAI interview questions
- Batched Key Fetch CallbacksAnrok · PHONE SCREEN
- Earliest Car for Each PassengerWhatNot · PHONE SCREENWhatNot interview questions
- Stateful Paginated Fetch NLyft · PHONE SCREENLyft interview questions