C# math solution by using Math.Log and Math.Ceiling


  • 0
    N
    public class Solution {
        public int PoorPigs(int buckets, int minutesToDie, int minutesToTest) {
            var n = minutesToTest / minutesToDie +1;
            var x = Math.Log(buckets, n);
            return (int) Math.Ceiling(x);
        }
    }
    

Log in to reply
 

Looks like your connection to LeetCode Discuss was lost, please wait while we try to reconnect.