Ctrl K

Tiles Into a Full Square

Easy
A tiler has tiles identical square tiles and wants to lay them out as one solid square, using every single tile. Return True if that is possible (that is, tiles equals k · k for some integer k), and False otherwise. Do not use built-in square-root helpers such as sqrt, isqrt or ** 0.5.
Example 1
tiles=36 → True

36 tiles make a 6 × 6 square.

Example 2
tiles=20 → False

4 × 4 = 16 is too few and 5 × 5 = 25 too many, so no square works.

Example 3
tiles=1 → True
Constraints
  • 1 ≤ tiles ≤ 2³¹ − 1
Have you seen this problem in a real interview?
Solved by0
Tried by0
Submissions0
Acceptance—
Topics
Similar problemsWhole Square Root EasyThe Lost Ticket EasyFull Pyramid Rows EasyDigit of Endless Counting MediumA Base of All Ones Hard
loading Python…
Input
tiles=36
Expected
True

Run checks the first 3 tests in your browser. Submit checks all 41 tests on the server, hidden ones included.