Resolve Visible User Features
Updated
Problem statement
You are given one user and a list of product features. Each feature row has the form featureId,priority,abTest,locations,conflicts.
priorityis an integer.abTestistrueorfalse.locationsis a|-separated list of allowed locations.conflictsis a|-separated list of feature IDs, or-when there are none.
A feature is initially eligible when the user's location appears in its location list and either its A/B test is disabled or the user's ID is even. An explicitly opted-in feature bypasses only the A/B-test check; it must still allow the user's location. An explicitly opted-out feature is never eligible, even when every other rule passes.
Resolve conflicts among eligible features in descending priority order. Break equal-priority ties by the feature's input position. Select a feature only when it does not conflict with an already selected feature. Treat a conflict named by either feature as a conflict between both features. Return the selected feature IDs in their original input order.
Function
resolveVisibleFeatures(userId: int, location: String, features: String[], optIn: String[], optOut: String[]) → String[]Examples
Example 1
userId = 4location = "US"features = ["fast_pay,10,true,US|CA,legacy_pay","legacy_pay,5,false,US,fast_pay","eu_dashboard,8,false,EU,-"]optIn = []optOut = []return = ["fast_pay"]Both US payment features are eligible, but they conflict. fast_pay has the higher priority, so only it remains visible.
Example 2
userId = 3location = "US"features = ["fast_pay,10,true,US|CA,legacy_pay","legacy_pay,5,false,US,fast_pay"]optIn = ["fast_pay"]optOut = []return = ["fast_pay"]The odd user would normally fail the A/B-test rule, but the opt-in bypasses that check. The higher-priority feature then wins the conflict.
Example 3
userId = 4location = "US"features = ["fast_pay,10,true,US|CA,legacy_pay","legacy_pay,5,false,US,fast_pay"]optIn = []optOut = ["fast_pay"]return = ["legacy_pay"]The explicit opt-out removes fast_pay, leaving the otherwise eligible legacy feature.
Constraints
1 <= features.length <= 500.- Feature IDs are unique non-empty ASCII strings without
,,|, or whitespace. - Every feature row has exactly five comma-separated fields and a valid integer priority.
- Every location list is non-empty;
conflictsis either-or a list of known feature IDs. optInandoptOutcontain unique known feature IDs and are disjoint.- All string comparisons are case-sensitive.
More Stripe Phone Screen questions
- Business Account KYC Verification — Parts 1–5PHONE SCREEN · Seen Nov 2026
- Financial Account LedgerOA · PHONE 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
- Pins Violation Log QueriesPinterest · PHONE SCREENPinterest interview questions
- Resource Reconciler: Plan and Apply CreatesPerplexity AI · PHONE SCREENPerplexity AI interview questions
- Credit Card Command ProcessorChime · PHONE SCREEN
- Popular and Instant-Runoff Election WinnersCoursera · PHONE SCREEN
- AI Role: Collection with Add and Remove OperationsApple · PHONE SCREENApple interview questions
- Read a File from Distributed ChunksHudson River Trading · ONSITE INTERVIEWHudson River Trading interview questions
- HTTP Request RedirectionAmazon · OA
- P&L Leaderboard OperationsBloomberg LP · ONSITE INTERVIEWBloomberg LP interview questions
- Aggregate Paginated Project Run RecordsReplit · OA
- Parcel Attribute Store with TTLAirbnb · OAAirbnb interview questions