I came across this question to find the maximum number of Collinear Points.
I have used a Binary Search Tree(BST) structure to keep track of all the gradients between the different points. Another approach which could have been simpler would have been to use a HashMap. However, considering that there would be a limited number of gradients, unless its a curve... a HashMap would have resulted in occupying far much space compared to a BST.
Here's my attempt at it.
I have used a Binary Search Tree(BST) structure to keep track of all the gradients between the different points. Another approach which could have been simpler would have been to use a HashMap. However, considering that there would be a limited number of gradients, unless its a curve... a HashMap would have resulted in occupying far much space compared to a BST.
Here's my attempt at it.