Skip to content

1037. Valid Boomerang 👎

  • Time: $O(1)$
  • Space: $O(1)$
1
2
3
4
5
6
7
class Solution {
 public:
  bool isBoomerang(vector<vector<int>>& points) {
    return (points[1][0] - points[0][0]) * (points[2][1] - points[1][1]) !=
           (points[1][1] - points[0][1]) * (points[2][0] - points[1][0]);
  }
};
1
2
3
4
5
6
7
class Solution {
  public boolean isBoomerang(int[][] points) {
    return                                                               //
        (points[1][0] - points[0][0]) * (points[2][1] - points[1][1]) != //
        (points[1][1] - points[0][1]) * (points[2][0] - points[1][0]);
  }
}
1
2
3
4
class Solution:
  def isBoomerang(self, points: list[list[int]]) -> bool:
    return ((points[1][0] - points[0][0]) * (points[2][1] - points[1][1]) !=
            (points[1][1] - points[0][1]) * (points[2][0] - points[1][0]))