Input: arr[] = {{5, 0}, {4, 0}, {3, 0}, {2, 0}, {1, 0}}, P = (0, 0)
Output: (1, 0) (2, 0) (3, 0) (4, 0) (5, 0)
Explanation:
Distance between (0, 0) and (1, 0) = 1
Distance between (0, 0) and (2, 0) = 2
Distance between (0, 0) and (3, 0) = 3
Distance between (0, 0) and (4, 0) = 4
Distance between (0, 0) and (5, 0) = 5
Hence, the sorted array of points will be: {(1, 0) (2, 0) (3, 0) (4, 0) (5, 0)}
Input: arr[] = {{5, 0}, {0, 4}, {0, 3}, {2, 0}, {1, 0}}, P = (0, 0)
Output: (1, 0) (2, 0) (0, 3) (0, 4) (5, 0)
Explanation:
Distance between (0, 0) and (1, 0) = 1
Distance between (0, 0) and (2, 0) = 2
Distance between (0, 0) and (0, 3) = 3
Distance between (0, 0) and (0, 4) = 4
Distance between (0, 0) and (5, 0) = 5
Hence, the sorted array of points will be: {(1, 0) (2, 0) (0, 3) (0, 4) (5, 0)}