# queues medium

Take the Bigger End

Coins lie in a row; each turn you may take from either end β€” and you're greedy, so you always grab the bigger end (front on a tie). πŸ€‘

You get the coins. Take until none remain and print your grand total. (Yes β€” it's ALL yours. The greed is about the order.)

Example:

Input: coins = [2, 9, 4, 7] Output: 22

Comparing ends each turn β€” 2 vs 7 (take 7), 2 vs 4 (take 4), 2 vs 9 (take 9), then just 2 left (take 2) β€” totals 7 + 4 + 9 + 2 = 22.

πŸ’‘ need a hint?

q-take-bigger-end.pyπŸ”’ given lines are locked β€” write your code in between
loading...