Problem · Greedy

Inventory Processes Survival Possibility

MediumAmazonFULLTIMEOA
See Amazon hiring insights

Within Amazon’s vast fulfillment system, there exist n distinct inventory tasks, each operated by bots[i] bots. These tasks compete, leading to conflict rounds every minute where two random tasks are chosen.

During each conflict:

  • The task with more bots defeats the other and absorbs all of its bots. 😱
  • If both tasks have an equal number of bots, one is randomly chosen as the winner and takes over the losing task’s bots. 🏳️
  • This sequence continues until only one inventory task remains active.

    Your objective is to determine which of these tasks have a chance to survive as the final remaining task in at least one possible sequence of events.

    Return the 1-based indices of all such tasks, and also please sort it in ascending order 📈.

    p.s. if you are applying for a L5 position, you may not want to miss this question..🤧

    Gooood news! We might found the shoe selling question: Selling Shoes

    The second question in the same batch..Will update once find reliable source..like always~~

    n = 5
    bots = [1, 6, 2, 7, 2]
    return = [2, 4]
    drafts saved locally
    public int[] inventoryProcessesSurvivalPossibility(int n, int[] robots) {
      // write your code here
    }
    
    n5
    bots[1, 6, 2, 7, 2]
    expected[2, 4]
    sign in to submit