Problem Solving/LeetCode
2023.10.29 Today's Challenge
fabichoi
2023. 10. 29. 23:45
https://leetcode.com/problems/poor-pigs/
Poor Pigs - LeetCode
Can you solve this real interview question? Poor Pigs - There are buckets buckets of liquid, where exactly one of the buckets is poisonous. To figure out which one is poisonous, you feed some number of (poor) pigs the liquid to see whether they will die or
leetcode.com
이게 왜 hard지..
class Solution:
def poorPigs(self, buckets: int, minutesToDie: int, minutesToTest: int) -> int:
pigs = 0
while (minutesToTest/minutesToDie+1) ** pigs < buckets:
pigs += 1
return pigs
반응형