Leetcode 458: Poor Pigs

  • A pig can be allowed to drink simultaneously on as many buckets as one would like, and the feeding takes no time.
  • After a pig has instantly finished drinking buckets, there has to be a cool down time of m minutes. During this time, only observation is allowed and no feedings at all.
  • Any given bucket can be sampled an infinite number of times (by an unlimited number of pigs).
class Solution {
public:
int poorPigs(int buckets, int minutesToDie, int minutesToTest) {
int times = minutesToTest / minutesToDie;
int result = 0;
while (pow(times + 1, result) < buckets) ++result;
return result;
}
};

--

--

--

Love podcasts or audiobooks? Learn on the go with our new app.

Recommended from Medium

Specifications for Developers: Starting with Gherkin-Part 1

Reduce Cost and Increase Productivity with Value Added IT Services from buzinessware — {link} -

Spring Boot Admin: How to use it

Power of Cloud​Formation, The Superman of AWS

Imperative, Functional, and Object-Oriented: Oh My!

Configuring Azure Blob Storage

Test the performance and impact of MariaDB configuration changes.

Academy XI Reflection Phase 1

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store
dume0011

dume0011

More from Medium

99. Recover Binary Search Tree 🚀

Everyday Things: Binary Search Trees & the Recursive Search Algorithm

Leetcode 34: Find First and Last Position of Element in Sorted Array

Why does Competitive Programming love Data Structures and Algorithms?