1/20
Loading...
🚁Decide the landing order
There are 4 landing spots. Each cell shows a coordinate (x, y) as 'xy'. E.g. 31 = (x=3, y=1). We sort by smaller x first, then by smaller y on ties!
Loading...
There are 4 landing spots. Each cell shows a coordinate (x, y) as 'xy'. E.g. 31 = (x=3, y=1). We sort by smaller x first, then by smaller y on ties!
Delivery drones must land on several spots (x, y) of a rooftop landing pad. To avoid collisions, the control tower grants landing permission in a fixed order. Land the spot with the smaller x-coordinate (west-to-east distance) first; if two spots share the same x, land the one with the smaller y-coordinate (south-to-north distance) first. Output the spots sorted by this rule.
points = [[3,1], [1,4], [3,0], [2,2]]
[[1,4], [2,2], [3,0], [3,1]]
By x: 1 < 2 < 3. Among x = 3, (3,0) comes before (3,1) because its y is smaller.