Bird
Raised Fist0
LLDsystem_design~20 mins

Pricing strategy (discounts, coupons) in LLD - Practice Problems & Coding Challenges

Choose your learning style10 modes available

Start learning this pattern below

Jump into concepts and practice - no test required

or
Recommended
Test this pattern10 questions across easy, medium, and hard to know if this pattern is strong
Challenge - 5 Problems
🎖️
Pricing Strategy Master
Get all challenges correct to earn this badge!
Test your skills under time pressure!
🧠 Conceptual
intermediate
2:00remaining
Understanding Discount Application Order

In a pricing system, a customer can apply a 10% discount coupon and a $5 fixed discount coupon. Which order of applying these discounts results in the lowest final price?

AApply only the higher discount, ignoring the other
BApply both discounts simultaneously by adding their values
CApply the 10% discount first, then subtract $5
DSubtract $5 first, then apply the 10% discount
Attempts:
2 left
💡 Hint

Think about how percentage discounts affect the price after fixed discounts.

Architecture
intermediate
2:00remaining
Designing Coupon Validation Component

Which component design best supports validating multiple coupon types (percentage, fixed amount, buy-one-get-one) in a scalable pricing system?

AA single monolithic validator that checks all coupon rules in one place
BSeparate validator classes for each coupon type implementing a common interface
CHardcoded if-else statements inside the pricing engine for each coupon type
DValidate coupons only on the client side before sending to server
Attempts:
2 left
💡 Hint

Consider maintainability and adding new coupon types in the future.

scaling
advanced
2:00remaining
Scaling Coupon Redemption System

Your e-commerce platform expects a sudden surge of 1 million coupon redemptions in one hour during a sale. Which approach best ensures system reliability and prevents coupon overuse?

AImplement distributed counters with eventual consistency and retry logic
BUse a centralized database with strong locking for coupon usage counters
CAllow unlimited coupon redemptions and reconcile usage offline later
DDisable coupons during high traffic to avoid race conditions
Attempts:
2 left
💡 Hint

Think about balancing consistency and performance under high load.

tradeoff
advanced
2:00remaining
Tradeoff Between Coupon Expiry Checks

Should coupon expiry be checked at coupon issuance or at order checkout? What is the main tradeoff?

ACheck at checkout to ensure validity but increase checkout latency
BCheck both at issuance and checkout to double confirm validity without tradeoffs
CCheck at issuance to reduce checkout latency but risk expired coupons being issued
DNever check expiry to simplify system design
Attempts:
2 left
💡 Hint

Consider user experience and system performance impacts.

estimation
expert
2:00remaining
Estimating Storage for Coupon Usage Logs

Your system logs every coupon redemption with user ID, coupon ID, timestamp, and order ID. Estimate the storage needed per day if you expect 500,000 redemptions daily. Assume each log entry is 200 bytes.

AApproximately 100 MB per day
BApproximately 100 GB per day
CApproximately 10 GB per day
DApproximately 1 GB per day
Attempts:
2 left
💡 Hint

Multiply number of entries by size per entry and convert bytes to GB.

Practice

(1/5)
1. What is the primary purpose of implementing discounts and coupons in a pricing strategy?
easy
A. To reduce product quality
B. To increase the base price of products
C. To make the checkout process slower
D. To attract more customers and increase sales volume

Solution

  1. Step 1: Understand the role of discounts and coupons

    Discounts and coupons are marketing tools used to lower prices temporarily.
  2. Step 2: Identify the business goal

    Lower prices attract more customers, which can increase sales volume and customer loyalty.
  3. Final Answer:

    To attract more customers and increase sales volume -> Option D
  4. Quick Check:

    Discounts and coupons = attract customers [OK]
Hint: Discounts attract customers by lowering prices [OK]
Common Mistakes:
  • Thinking discounts increase prices
  • Confusing discounts with product quality
  • Assuming coupons slow checkout
2. Which of the following is the correct way to represent a discount of 20% in a pricing system?
easy
A. discount = 20
B. discount = 2
C. discount = 0.2
D. discount = 200

Solution

  1. Step 1: Understand percentage representation in code

    Percentages are usually represented as decimals for calculations, so 20% is 0.2.
  2. Step 2: Check each option

    discount = 0.2 uses 0.2 which is correct; others are incorrect as they represent wrong values.
  3. Final Answer:

    discount = 0.2 -> Option C
  4. Quick Check:

    20% = 0.2 decimal [OK]
Hint: Use decimal for percentage (20% = 0.2) [OK]
Common Mistakes:
  • Using whole number 20 instead of decimal
  • Confusing 2 or 200 as percentage
  • Not converting percentage to decimal
3. Consider this code snippet for applying a coupon discount:
price = 100
coupon_discount = 15  # fixed amount
final_price = price - coupon_discount
print(final_price)

What will be the output?
medium
A. 85
B. 15
C. 100
D. 115

Solution

  1. Step 1: Understand the variables

    Price is 100, coupon_discount is 15 fixed amount.
  2. Step 2: Calculate final price

    final_price = 100 - 15 = 85.
  3. Final Answer:

    85 -> Option A
  4. Quick Check:

    100 - 15 = 85 [OK]
Hint: Subtract fixed coupon value from price [OK]
Common Mistakes:
  • Confusing discount as percentage
  • Adding instead of subtracting discount
  • Printing coupon_discount instead of final price
4. In the following code, what is the error that prevents correct discount application?
price = 200
discount = 20  # intended as 20%
final_price = price - discount
print(final_price)
medium
A. Price should be multiplied by discount directly
B. Discount should be converted to decimal before calculation
C. Discount should be added to price
D. No error, code is correct

Solution

  1. Step 1: Identify discount representation

    Discount is 20 but intended as 20%, so it should be 0.2 in decimal.
  2. Step 2: Correct calculation method

    final_price should be price - (price * discount_decimal), not price - discount integer.
  3. Final Answer:

    Discount should be converted to decimal before calculation -> Option B
  4. Quick Check:

    20% = 0.2 decimal needed [OK]
Hint: Convert percentage to decimal before subtracting [OK]
Common Mistakes:
  • Subtracting integer discount directly
  • Adding discount instead of subtracting
  • Ignoring percentage to decimal conversion
5. You are designing a system that applies multiple discounts: a 10% seasonal discount and a $5 coupon. If the original price is $50, what is the correct final price after applying both discounts sequentially?
hard
A. $40.5
B. $45
C. $40
D. $42

Solution

  1. Step 1: Apply the $5 coupon discount first

    $50 - $5 = $45.
  2. Step 2: Apply the 10% seasonal discount

    $45 * 0.9 = $40.5.
  3. Step 3: Sequential discounts

    Coupon before percentage discount yields $40.5.
  4. Final Answer:

    $40.5 -> Option A
  5. Quick Check:

    Coupon then percentage = 40.5 [OK]
Hint: Order of discounts affects final price [OK]
Common Mistakes:
  • Applying discounts in wrong order
  • Adding discounts instead of subtracting
  • Ignoring percentage vs fixed discount difference