Design a system that allows DoorDash’s consumers to add reviews on ordered food items. Consumers will earn rewards ($) based on the quality of the review.
Just for reference, rewards are paid on a monthly basis. An example of rules can be:
Upvotes | Rewards
50 | $0.5
100 | $1
1000 | $10
Up to $50 a month and max accumulated of $500.
这道 DoorDash 面试题本质上是在设计一个“按月结算的评论奖励系统”:用户在订餐后可以提交评价,系统根据评价质量(例如点赞数 / 上票数)发放奖励,并且奖励规则可能是分档的,还要受每月上限和累计上限约束。解题时通常要先澄清奖励计算方式,再把规则抽象成可配置的阈值表,便于后续扩展;实现上可以用哈希表或数据库记录用户月度奖励、累计奖励和每条评论的质量指标,计算时按规则匹配对应档位并做封顶处理。若继续深入设计,还需要考虑幂等性、重复提交、月度结算任务、并发更新以及大规模用户下的存储与查询性能。