# 1037. Valid Boomerang
A boomerang is a set of 3 points that are all distinct and not in a straight line.
Given a list of three points in the plane, return whether these points are a boomerang.
Example 1:
Input: [[1,1],[2,3],[3,2]]
Output: true
Example 2:
Input: [[1,1],[2,2],[3,3]]
Output: false
# Solution
Approach 1: calculate the slope.
# Code (Python)
Approach 1:
class Solution:
def isBoomerang(self, p: List[List[int]]) -> bool:
'''if points[0] == points[1] or points[1] == points[2] or points[2] == points[0]:
return False
points.sort()
if points[0][0] == points[1][0]:
return points[2][0] != points[0][0]
if points[1][0] == points[2][0]:
return points[0][0] != points[1][0]
if points[0][0] == points[2][0]:
return points[1][0] != points[0][0]
return (points[1][1] - points[0][1]) / (points[1][0] - points[0][0]) != (points[2][1] - points[0][1]) / (points[2][0] - points[0][0])'''
# or just use multiplication to avoid same locations and divide by 0
return (p[0][0] - p[1][0]) * (p[0][1] - p[2][1]) != (p[0][0] - p[2][0]) * (p[0][1] - p[1][1])
# Code (C++)
Approach 1:
Approach 2: