Practice Poor Pigs
Read the task, work through the examples, and check your approach against the constraints. Use the original LeetCode task for coding and submissions.
Problem Statement
The number of liquid buckets is given by buckets. Exactly one is poisonous. You have minutesToTest minutes to identify it. In each testing round, choose live pigs and assign any number of buckets to each one; a bucket may be assigned to multiple pigs. Feeding takes no time, and each pig drinks all its assigned samples simultaneously. Then wait minutesToDie minutes without feeding any other pigs. Pigs given poison die at the end of that wait; the others survive and may participate in another round. Return the fewest pigs that guarantee identifying the poisonous bucket within the time limit.
Source: Poor Pigs on LeetCode. Use the original task for its coding environment and submissions.
Examples
# Example 1
buckets = 4, minutesToDie = 15, minutesToTest = 15
2
# Example 2
buckets = 4, minutesToDie = 15, minutesToTest = 30
2
Constraints
Related LeetCode Problems
Practice more problems similar to Poor Pigs.
Review your practice with PhantomCodeAI
After trying the problem yourself, use the app to discuss your approach, complexity, and edge cases.