Microsoft OA Question

Правка en1, от Lamentis, 2022-08-20 11:46:39

Q) Given a 2D array of size n that represents the x and y coordinates([x,y]), find the number of collinear triplets.If collinear triplets>1e9, then return -1.

N<=1000

----------------------------------------------- This question came in yesterday's Microsoft OA. I was not able to come up with an efficient solution and ultimately wrote an O(n^3) solution using the idea that the area of triangle formed by three collinear points is 0.

Please suggest an efficient solution.

История

 
 
 
 
Правки
 
 
  Rev. Язык Кто Когда Δ Комментарий
en1 Английский Lamentis 2022-08-20 11:46:39 506 Initial revision (published)