Easy
Poor Pigs — Python
Full explanation · Time O(n) · Space O(1)
# Time: O(1)
# Space: O(1)
import math
class Solution(object):
def poorPigs(self, buckets, minutesToDie, minutesToTest):
"""
:type buckets: int
:type minutesToDie: int
:type minutesToTest: int
:rtype: int
"""
return int(math.ceil(math.log(buckets) / math.log(minutesToTest / minutesToDie + 1)))