mirror of
https://gitee.com/coder-xiaomo/leetcode-problemset
synced 2025-09-04 23:11:41 +08:00
国外版
This commit is contained in:
42
算法题(国外版)/maximum-ice-cream-bars.html
Normal file
42
算法题(国外版)/maximum-ice-cream-bars.html
Normal file
@@ -0,0 +1,42 @@
|
||||
<p>It is a sweltering summer day, and a boy wants to buy some ice cream bars.</p>
|
||||
|
||||
|
||||
|
||||
<p>At the store, there are <code>n</code> ice cream bars. You are given an array <code>costs</code> of length <code>n</code>, where <code>costs[i]</code> is the price of the <code>i<sup>th</sup></code> ice cream bar in coins. The boy initially has <code>coins</code> coins to spend, and he wants to buy as many ice cream bars as possible. </p>
|
||||
|
||||
|
||||
|
||||
<p>Return <em>the <strong>maximum</strong> number of ice cream bars the boy can buy with </em><code>coins</code><em> coins.</em></p>
|
||||
|
||||
|
||||
|
||||
<p><strong>Note:</strong> The boy can buy the ice cream bars in any order.</p>
|
||||
|
||||
|
||||
|
||||
<p> </p>
|
||||
|
||||
<p><strong>Example 1:</strong></p>
|
||||
|
||||
|
||||
|
||||
<pre>
|
||||
|
||||
<strong>Input:</strong> costs = [1,3,2,4,1], coins = 7
|
||||
|
||||
<strong>Output:</strong> 4
|
||||
|
||||
<strong>Explanation: </strong>The boy can buy ice cream bars at indices 0,1,2,4 for a total price of 1 + 3 + 2 + 1 = 7.
|
||||
|
||||
</pre>
|
||||
|
||||
|
||||
|
||||
<p><strong>Example 2:</strong></p>
|
||||
|
||||
|
||||
|
||||
<pre>
|
||||
|
||||
<strong>Input:</strong> costs = [10,6,8,7,7,8], coins = 5
|
||||
|
Reference in New Issue
Block a user