mirror of
https://gitee.com/coder-xiaomo/leetcode-problemset
synced 2025-09-12 02:41:42 +08:00
批量更新数据
This commit is contained in:
@@ -1,13 +1,11 @@
|
||||
<p>有两个水壶,容量分别为 <code>jug1Capacity</code> 和 <code>jug2Capacity</code> 升。水的供应是无限的。确定是否有可能使用这两个壶准确得到 <code>targetCapacity</code> 升。</p>
|
||||
|
||||
<p>如果可以得到 <code>targetCapacity</code> 升水,最后请用以上水壶中的一或两个来盛放取得的 <code>targetCapacity</code> 升水。</p>
|
||||
<p>有两个水壶,容量分别为 <code>x</code> 和 <code>y</code> 升。水的供应是无限的。确定是否有可能使用这两个壶准确得到 <code>target</code> 升。</p>
|
||||
|
||||
<p>你可以:</p>
|
||||
|
||||
<ul>
|
||||
<li>装满任意一个水壶</li>
|
||||
<li>清空任意一个水壶</li>
|
||||
<li>从一个水壶向另外一个水壶倒水,直到装满或者倒空</li>
|
||||
<li>将水从一个水壶倒入另一个水壶,直到接水壶已满,或倒水壶已空。</li>
|
||||
</ul>
|
||||
|
||||
<p> </p>
|
||||
@@ -15,28 +13,37 @@
|
||||
<p><strong>示例 1:</strong> </p>
|
||||
|
||||
<pre>
|
||||
<strong>输入:</strong> jug1Capacity = 3, jug2Capacity = 5, targetCapacity = 4
|
||||
<strong>输入:</strong> x = 3,y = 5,target = 4
|
||||
<strong>输出:</strong> true
|
||||
<strong>解释</strong>:来自著名的 <a href="https://www.youtube.com/watch?v=BVtQNK_ZUJg"><em>"Die Hard"</em></a></pre>
|
||||
<strong>解释:
|
||||
</strong>按照以下步骤操作,以达到总共 4 升水:
|
||||
1. 装满 5 升的水壶(0, 5)。
|
||||
2. 把 5 升的水壶倒进 3 升的水壶,留下 2 升(3, 2)。
|
||||
3. 倒空 3 升的水壶(0, 2)。
|
||||
4. 把 2 升水从 5 升的水壶转移到 3 升的水壶(2, 0)。
|
||||
5. 再次加满 5 升的水壶(2, 5)。
|
||||
6. 从 5 升的水壶向 3 升的水壶倒水直到 3 升的水壶倒满。5 升的水壶里留下了 4 升水(3, 4)。
|
||||
7. 倒空 3 升的水壶。现在,5 升的水壶里正好有 4 升水(0, 4)。
|
||||
参考:来自著名的 <a href="https://www.youtube.com/watch?v=BVtQNK_ZUJg"><em>"Die Hard"</em></a></pre>
|
||||
|
||||
<p><strong>示例 2:</strong></p>
|
||||
|
||||
<pre>
|
||||
<strong>输入:</strong> jug1Capacity = 2, jug2Capacity = 6, targetCapacity = 5
|
||||
<strong>输入:</strong> x = 2, y = 6, target = 5
|
||||
<strong>输出:</strong> false
|
||||
</pre>
|
||||
|
||||
<p><strong>示例 3:</strong></p>
|
||||
|
||||
<pre>
|
||||
<strong>输入:</strong> jug1Capacity = 1, jug2Capacity = 2, targetCapacity = 3
|
||||
<strong>输入:</strong> x = 1, y = 2, target = 3
|
||||
<strong>输出:</strong> true
|
||||
</pre>
|
||||
<b>解释:</b>同时倒满两个水壶。现在两个水壶中水的总量等于 3。</pre>
|
||||
|
||||
<p> </p>
|
||||
|
||||
<p><strong>提示:</strong></p>
|
||||
|
||||
<ul>
|
||||
<li><code>1 <= jug1Capacity, jug2Capacity, targetCapacity <= 10<sup>6</sup></code></li>
|
||||
<li><code>1 <= x, y, target <= 10<sup>3</sup></code></li>
|
||||
</ul>
|
||||
|
Reference in New Issue
Block a user