Question: C++ or Java or any other language Arrange Points You are given N points ( X i , Y i ) where 1 i N

C++ or Java or any other language

Arrange Points You are given N points ( X i , Y i ) where 1 i N . Print N points in the ascending order with respect to X i . If there are more than one point with the same X value, print the point with the bigger Y value first. Input format In the first line: given an integer N. Then N lines follow, in each line, given a point ( X i , Y i ) . Output format Print the N points ,in the order illustrated in the question, in the following format: " X i Y i "" without quotes. Print each point in a new line. Constraints: 1 N 1000 . 1000 X i , Y i 1000 .

Sample Input 5 2 5 3 6 1 2 3 5 5 1

Sample Output 1 2 2 5 3 6 3 5 5 1

Explanation First we sort the points according to the increasing X co-ordinate but as (3,6) and (3,5) have the same X co-ordinate we place (3,6) above (3,5) because it has a greater Y co-ordinate. Note: Your code should be able to convert the sample input into the sample output. However, this is not enough to pass the challenge, because the code will be run on multiple test cases. Therefore, your code must solve this problem statement.

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!