Skip to main content

4 docs tagged with "simulation"

View all tags

Last Stone Weight

This question is asked by Amazon. You are given a group of stones, all of which have a positive weight. At each turn, we select the heaviest two stones and smash them together. When smashing these two stones together, one of two things can happen:

Lemonade Change

This question is asked by Amazon. You're running a popsicle stand where each popsicle costs $5. Each customer you encountered pays with either a $5 bill, a $10 bill, or a $20 bill and only buys a single popsicle. The customers that come to your stand come in the ordered given by the customers array where customers[i] represents the bill the ith customer pays with. Starting with $0, return whether or not you can serve all the given customers while also giving the correct amount of change.

Spiral Matrix

Given a 2D matrix, return a list containing all of its elements in spiral order.