Skip to content

Commit cfd5285

Browse files
committed
Update: question 458
1 parent f489a41 commit cfd5285

File tree

2 files changed

+21
-6
lines changed

2 files changed

+21
-6
lines changed

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -591,7 +591,7 @@ LeetCode Problems' Solutions
591591
| <span id="461">461</span> | [Hamming Distance](https://leetcode.com/problems/hamming-distance "汉明距离") | [Go](https://github.com/openset/leetcode/tree/master/problems/hamming-distance) | Easy |
592592
| <span id="460">460</span> | [LFU Cache](https://leetcode.com/problems/lfu-cache "LFU缓存") | [Go](https://github.com/openset/leetcode/tree/master/problems/lfu-cache) | Hard |
593593
| <span id="459">459</span> | [Repeated Substring Pattern](https://leetcode.com/problems/repeated-substring-pattern "重复的子字符串") | [Go](https://github.com/openset/leetcode/tree/master/problems/repeated-substring-pattern) | Easy |
594-
| <span id="458">458</span> | [Poor Pigs](https://leetcode.com/problems/poor-pigs "可怜的小猪") | [Go](https://github.com/openset/leetcode/tree/master/problems/poor-pigs) | Easy |
594+
| <span id="458">458</span> | [Poor Pigs](https://leetcode.com/problems/poor-pigs "可怜的小猪") | [Go](https://github.com/openset/leetcode/tree/master/problems/poor-pigs) | Hard |
595595
| <span id="457">457</span> | [Circular Array Loop](https://leetcode.com/problems/circular-array-loop "环形数组循环") | [Go](https://github.com/openset/leetcode/tree/master/problems/circular-array-loop) | Medium |
596596
| <span id="456">456</span> | [132 Pattern](https://leetcode.com/problems/132-pattern "132模式") | [Go](https://github.com/openset/leetcode/tree/master/problems/132-pattern) | Medium |
597597
| <span id="455">455</span> | [Assign Cookies](https://leetcode.com/problems/assign-cookies "分发饼干") | [Go](https://github.com/openset/leetcode/tree/master/problems/assign-cookies) | Easy |

problems/poor-pigs/README.md

Lines changed: 20 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -9,12 +9,27 @@
99

1010
[Next >](https://github.com/openset/leetcode/tree/master/problems/repeated-substring-pattern "Repeated Substring Pattern")
1111

12-
## 458. Poor Pigs (Easy)
12+
## 458. Poor Pigs (Hard)
1313

14-
<p>There are 1000 buckets, one and only one of them contains poison, the rest are filled with water. They all look the same. If a pig drinks that poison it will die within 15 minutes. What is the minimum amount of pigs you need to figure out which bucket contains the poison within one hour.</p>
14+
<p>There are 1000 buckets, one and only one of them is poisonous, while the rest are filled with water. They all look identical. If a pig drinks the poison it will die within 15 minutes. What is the minimum amount of pigs you need to figure out which bucket is poisonous within one hour?</p>
1515

16-
<p>Answer this question, and write an algorithm for the follow-up general case.</p>
16+
<p>Answer this question, and write an algorithm for the general case.</p>
1717

18-
<p><b>Follow-up: </b></p>
18+
<p>&nbsp;</p>
1919

20-
<p>If there are n buckets and a pig drinking poison will die within m minutes, how many pigs (x) you need to figure out the &quot;poison&quot; bucket within p minutes? There is exact one bucket with poison.</p>
20+
<p><b>General case: </b></p>
21+
22+
<p>If there are <code>n</code> buckets and a pig drinking poison will die within <code>m</code> minutes, how many pigs (<code>x</code>) you need to figure out the <strong>poisonous</strong>&nbsp;bucket within <code>p</code> minutes? There is exactly one bucket with poison.</p>
23+
24+
<p>&nbsp;</p>
25+
26+
<p><strong>Note:</strong></p>
27+
28+
<ol>
29+
<li>A pig can be allowed to drink simultaneously on as many buckets as one would like, and the feeding takes no time.</li>
30+
<li>After a pig has instantly finished drinking buckets, there has to be a <strong>cool down time</strong> of <em>m&nbsp;</em>minutes. During this time, only observation is allowed and no feedings at all.</li>
31+
<li>Any given bucket can be sampled an infinite number of times (by an unlimited number of pigs).</li>
32+
</ol>
33+
34+
### Related Topics
35+
[[Math](https://github.com/openset/leetcode/tree/master/tag/math/README.md)]

0 commit comments

Comments
 (0)