Amazon OA SDE 2 discussion

Posted
7 Aug 2026
40 reads

Summary

I was asked the "Maximum Coins From K Consecutive Bags" problem during an online assessment.

How it went

Got asked this question but with a different language. 3413. Maximum Coins From K Consecutive Bags

Questions asked (1)

  1. 01

    Maximum Coins From K Consecutive Bags

    Data Structures & Algorithms · Medium

    You are given an array bags of length n where bags[i] represents the number of coins in the i‑th bag. You can select exactly k consecutive bags in one operation and collect all coins from those bags. After each operation, the selected bags become empty (their values become 0). You repeat the operation until all bags are empty. Return the maximum total number of coins you can collect.

    Example

    Input: bags = [1,2,3,4,5], k = 2
    Output: 12
    Explanation:
    - First select bags[3] and bags[4] (values 4 and 5) -> collect 9, bags become [1,2,3,0,0]
    - Then select bags[1] and bags[2] (values 2 and 3) -> collect 5, bags become [1,0,0,0,0]
    - Finally select bags[0] and bags[1] (value 1 and 0) -> collect 1, total = 9+5+1 = 15.
    

    Note: The above example is illustrative; actual optimal selections may differ.

    Open the problem

Know someone preparing? Send it to them:WhatsAppLinkedInX

Interviewed at Interview Experience recently?

Write up your rounds while you still remember the questions. It helps the next person more than you would think.

Share your experience
Discussion 0

Questions for the author, or how your own interview compared.

Join the discussion

Sign in with Google to comment or ask the author a question.

No comments yet

Be the first to share your thoughts and start the discussion!