From 156ab64a8232c4ac47b73d3806af379b10940755 Mon Sep 17 00:00:00 2001 From: Gabriel Donnan <47415809+gabedonnan@users.noreply.github.com> Date: Thu, 12 Jan 2023 10:55:08 +0000 Subject: [PATCH] Create max-ice-cream.py maximum icecream that can be bought --- max-ice-cream.py | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) create mode 100644 max-ice-cream.py diff --git a/max-ice-cream.py b/max-ice-cream.py new file mode 100644 index 0000000..3641702 --- /dev/null +++ b/max-ice-cream.py @@ -0,0 +1,16 @@ +class Solution(object): + def maxIceCream(self, costs, coins): + """ + :type costs: List[int] + :type coins: int + :rtype: int + """ + costs = sorted(costs) + count = 0 + for c in costs: + if c <= coins: + coins -= c + count += 1 + else: + return count + return count