← Questions

Decide which features a user sees

0
StripeCodingLast asked Nov 2023

Each product feature has an ID, a priority, whether it is behind an A/B test, the locations where it is allowed, and the features it conflicts with. For one user (an ID and a location), decide which features they see.

A feature is eligible when the user's location is allowed and either it has no A/B test or the user falls in the test group (even user IDs). A user can opt in to a feature, which skips the A/B check but not the location check, or opt out, which hides it. Then resolve conflicts: go through eligible features from highest priority down (ties by input order) and keep each one that doesn't conflict with a feature already kept; a conflict listed on either side counts. Return the kept features in input order.

Write and test your solution herePython in your browser, the question's tests level by level, every submission kept for you.Sign in to start coding