Tiles That Make a Rectangle
Each tile is [x1, y1, x2, y2]: its bottom left corner (x1, y1) and its top right corner (x2, y2), with sides parallel to the axes.
Return True if the tiles together cover a rectangle exactly, with no gap and no two tiles overlapping, otherwise False. Tiles may touch along their edges.
Example 1
tiles [[0,0,2,1],[2,0,3,2],[0,1,2,2]]
returns true
Two flat tiles stacked on the left and one upright tile on the right fill a rectangle 3 wide and 2 high.
Example 2
tiles [[0,0,1,1],[1,1,2,2]]
returns false
The two squares touch only at a corner, so half of the square around them stays empty.
Example 3
tiles [[0,0,2,1],[1,0,3,1]]
returns false
The tiles overlap between x = 1 and x = 2.
Constraints
1 <= len(tiles) <= 400 <= x1 < x2 <= 10**40 <= y1 < y2 <= 10**4
Write it in your browser, against the clock. The model solution, stepped through line by line, comes after.
More Hash maps problems
- Word Pairs That Make a MirrorHard
- Words Glued TogetherHard
- Already Seen FlagsBeginner
- Best Score per NameBeginner
- Check if the Sentence Is PangramBeginner
- Count Elements With a NextBeginner
- Difference of Two ArraysBeginner
- First Repeated WordBeginner