Continue learning
Practice related DSA questions in the same topic.
Return the greatest integer whose square is at most the nonnegative target. The values list is unused.
Return the greatest integer whose square is at most the nonnegative target. The values list is unused.
def solve(values, target): low = 0 high = target best = 0 while (low <= high): mid = (low + ((high - low) // 2)) if ((mid * mid) <= target): best = mid low = (mid + 1) else: high = (mid - 1) return bestEmpty array
Test candidate root 19 against the tile budget.
Test candidate root 19 against the tile budget.
Find the widest square tiled floor you can cover with a fixed number of tiles.
Square a candidate root; a square within budget makes every smaller root feasible too.
O(log(t + 2)) time · O(1) auxiliary space
Worked example · {"values":[],"target":38} ⇒ 6
Edge case 1 · {"values":[],"target":0} ⇒ 0
Edge case 2 · {"values":[],"target":1} ⇒ 1
Exact equality is unnecessary for numbers between consecutive squares.
How would you avoid overflow for very large integer targets?