1954. Minimum Garden Perimeter to Collect Enough Apples

Обновлено: 2024-03-12
1 мин
[]

Содержание

LeetCode problem 1954

class Solution:
    def minimumPerimeter(self, neededApples: int) -> int:
        l, r = 1, 100000
        while l < r:
            mid = (l + r) >> 1
            if 2 * mid * (mid + 1) * (2 * mid + 1) >= neededApples:
                r = mid
            else:
                l = mid + 1
        return l * 8