Trains the technique from
LeetCode 69Sqrt(x)This is an original problem, written from a brief that listed the technique, the difficulty, the topics, the function shape and the input bounds — none of that problem's wording, examples, hints or editorials. The link is there so you can map your practice onto the standard set.
Same function shape, different story and different numbers.
A landscaper has tiles identical square paving stones on the pallet and wants to lay one solid square patio. Stones are laid whole, never cut, and any stones left over simply stay on the pallet.
Return the side length of the largest square patio that can be laid, counted in stones along one edge. Equivalently, return the largest integer side for which side * side is at most tiles.
Work it out with integer arithmetic: do not call a library square-root routine and do not use an exponentiation operator.
Example 1
A patio 5 stones on a side takes 25 stones, so the pallet of 27 covers it and 2 stones stay behind.
Example 2
A patio 10 stones on a side takes exactly 100 stones, so the pallet is used up and nothing is left over.
Example 3
A single stone is already a square patio 1 stone on a side, and the other 2 stones stay on the pallet.
The editor is preloaded with this. It matches the parent problem's shape, so a solution that works here transfers to a judge unchanged.
def largest_square_side(tiles: int) -> int:public int largestSquareSide(int tiles)See the step-by-step animation, the intuition, and clean code in every language — free, no credit card.