Promotion Rule Engine
Given a JSON input containing a user's cart context and a list of promotion rules with conditions (e.g., EQUAL, GREATER_THAN), evaluate which promotions apply and return the list of applicable promotion IDs.
Question Timeline
See when this question was last asked and where, including any notes left by other candidates.
Early July, 2026
You're given a JSON context representing a user's cart and session: { "context": { "user": { "userId": "u123", "isWowUser": true }, "cart": { "totalValue": 750, "items": [ { "itemId": "i1", "itemValue": 250 }, { "itemId": "i2", "itemValue": 500 } ] } }, "rules": [ { "promotionId": "p1", "value": 100, "conditions": [ { "ops": "EQUAL", "field": "user.isWowUser", "value": true }, { "ops": "GREATER_THAN", "field": "cart.totalValue", "value": 500 } ] }, { "promotionId": "p2", "value": 50, "conditions": [ { "ops": "EQUAL", "field": "user.isWowUser", "value": false } ] } ] } write code for this input is context and output is application promotionIds
Hello Interview Premium
Your account is free and you can post anonymously if you choose.