1p3a Experience · May 2026

decagon tech phone screen interview: cooking app cart implementation

SWE Phone Screen newgrad
2 upvotes

Interview Experience

第二轮店面还是扣定,之前面筋没有遇到过,发出来帮助准备他家的人,求加米!!

以下内容需要积分高于 150 您已经可以浏览

构建一个烹饪 app 的购物车:

"""

You're building a shopping cart for a cooking app. Users can add recipes

to their cart. Each recipe has a list of ingredients (e.g., Chicken, Garlic).

When the same ingredient appears across multiple recipes, the total count qualifies

for bulk discounts.


API


  • add_recipe(recipe_name):      adds a recipe to the cart. No-op i...

Full Details

第二轮店面还是扣定,之前面筋没有遇到过,发出来帮助准备他家的人,求加米!!

以下内容需要积分高于 150 您已经可以浏览

构建一个烹饪 app 的购物车:

"""

You're building a shopping cart for a cooking app. Users can add recipes

to their cart. Each recipe has a list of ingredients (e.g., Chicken, Garlic).

When the same ingredient appears across multiple recipes, the total count qualifies

for bulk discounts.


API


  • add_recipe(recipe_name):      adds a recipe to the cart. No-op if already in cart.

  • remove_recipe(recipe_name):   removes a recipe from the cart. No-op if not in cart.

  • get_total_discount():

returns the total discount in dollars.

Only one of each recipe can be in the cart at any time.

Example: Cart contains Chicken Parm & Stir Fry. Both contain Garlic, so the cart

contains Garlic at quantity 2. Garlic has discounts [(2, 3), (4, 8)].

0-1 recipes with Garlic -> $0 off  (no threshold met)

2-3 recipes with Garlic -> $3 off  (meets threshold 2)

4+ recipes with Garlic  -> $8 off  (meets threshold 4)

Implement add_recipe, remove_recipe, and get_total_discount.

"""

"""


Part 2: Undo / Redo


Add support for undoing and redoing cart operations.

  • undo(): reverses the most recent operation.

  • redo(): re-applies the most recently undone operation.

  • Performing a new operation resets the redo history.

  • undo() when there is nothing to undo is a no-op. Same for redo().

  • get_total_discount() reflects the current state after any undos/redos.

"""

吐槽下面试官abc小哥,迟到4分钟不说,全程无交流,slack回消息,体感很差