Search
⌘K

Leetcode 1954. Minimum Garden Perimeter to Collect Enough Apples

Given apples at each integer point (i, j) equal to |i|+|j|, find the smallest axis-aligned square centered at the origin whose contained lattice points sum to at least neededApples; this reduces to deriving a closed-form formula for the total apples inside a square of half-side k and binary-searching the minimal k (perimeter = 8·k) under large (≤1e15) inputs.


Question Timeline

See when this question was last asked and where, including any notes left by other candidates.

Comments

Your account is free and you can post anonymously if you choose.