Binary Search || Beats 100% || Simple and Straightforward || C++
Intuition\nThe goal is to find the minimum number x such that (t+1)^x >= n, where t = ToDie/ToTest. This essentially means finding the minimum number of pigs re
# Intuition\nThe goal is to find the minimum number `x` such that `(t+1)^x >= n`, where `t = ToDie/ToTest`. This essentially means finding the minimum number of pigs required to determine the poisoned bucket within the given constraints. The approach involves a straightforward binary search implementation.\n\n# Complexity\n- Time complexity: $$O(log n)$$\n- Space complexity: $$O(1)$$\n\n```cpp\nclass Solution {\npublic:\n    bool good(int mid, int t, int n) {\n      return pow(t+1, mid) >= n;\n    }\n    int poorPigs(int n, int ToDie, int ToTest) {\n      int t = ToTest / ToDie;\n      int l = 0;\n      int r = n;\n      while (l < r) {\n        int mid = l + (r - l) / 2;\n        if (good(mid, t, n))\n          r = mid;\n        else\n          l = mid + 1;\n      }\n      return l;\n    }\n};\n
['Binary Search', 'C++']