Reputation: 107
Given n points in the xy plane, I need to find the number of right angled triangles that can be formed using these points as vertices. I did come up with a O(n3) solution where you take 3 vertices at a time and check if they form a right angled triangle. I wanted to know a more optimal solution for this problem.
Upvotes: 3
Views: 1763
Reputation: 11284
An O(n^2) solution could be something like this:
Upvotes: 6