The answer is option A
This is not exactly an easy question and and even after reading the Stack overflow link given in the best answer it didn’t really click. After reading the SO answer plotting the figure did the trick.
Using a brute-force algorithm we can compute the slope of each line i.e each pair of points. Since there are nC2 pairs of points the algorithm would take O(n^2) time.
We can model it into a greedy algorithm using the following argument – the points a(x1.y1) and b(x2,y2) that give the maximum slope are adjacent to each other in terms of their x coordinate, i.e their x coordinates are consecutive terms when sorted by x coordinate.
This is can be tested out using out figures and an idea of a convex boundary.
From the figure we can see that the maximum slope will be formed by p3 and p4 and these have adjacent x coordinates. This can be used to further restrict out sample space and our algorithm can be done in O(n) time.
Additionally we can also find counterexamples for all the other options.
Option B – If the x is proportionately large as the difference in the Y coordinates the slope will not increase
Option C – If the difference in x coordinates is minimum and Y coordinates change is 0 that will not be max either
The only real confusion is between Option A and D but since we proved A
The answer is A