Loading
Loading
A tiling tool must lay out square tiles in the largest square grid that fits within a given number of tiles. It needs the side length, as a whole number, with no floating-point surprises.
Given a non-negative integer n, return the largest integer r such that r × r ≤ n.
n = 30lo = 0, hi = 30the answer lies in this rangemid = 15225 > 30 → hi = 14mid = 749 > 30 → hi = 6mid = 39 ≤ 30 → lo = 3mid = 525 ≤ 30 → lo = 5mid = 636 > 30 → hi = 5; lo = hi = 55Sign in to keep a note here. It is free, and nobody else can see it.
Sign inExample 1
5 × 5 = 25 fits, 6 × 6 = 36 does not.
Example 2
49 is a perfect square.
Sign in to open hints.
Struggling is where the learning happens. Open this once you have genuinely tried, or once the hints have run out.
O(log n) time · O(1) space
Input. Run your code to watch it work on this input, one line at a time.
Running code is turned off on this deployment. You can still read the problem, write code, use hints and the visualizer.
Tab moves focus out of the editor. Press Ctrl+M to let Tab indent instead.
No results yet
Run your code against the sample tests, or submit to run the full suite.