Showing 3 of 4 questions
You are given an inventory of colored balls, each with a value equal to its count. Determine the maximum total value you can obtain by selling a limited number of these balls, given that each sale reduces the ball's value by one.
#1. Sell Diminishing-Valued Colored Balls
Design a data structure that supports insertion, deletion, and random element retrieval, all in constant time on average. You'll need to handle edge cases carefully to achieve O(1) complexity.
#2. Insert Delete GetRandom O(1)
Imagine people in a circle, eliminating every kth person. Determine who is the last person remaining after this process.
#3. Find the Winner of the Circular Game