"""
https://leetcode.com/problems/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


Note:

points.length == 3
points[i].length == 2
0 <= points[i][j] <= 100
"""

# time complexity: O(1), space complexity: O(1)

class Solution:
    def isBoomerang(self, points: List[List[int]]) -> bool:
        s = set()
        for a,b in points:
            s.add((a,b))
        if len(s) < 3:
            return False
        if points[0][0] == points[1][0] == points[2][0]:
            return False
        elif points[0][0] == points[1][0] or points[0][0] == points[2][0] or points[1][0] == points[2][0]:
            return True
        else:
            k1 = (points[1][1]-points[0][1]) / (points[1][0]-points[0][0])
            k2 = (points[2][1]-points[1][1]) / (points[2][0]-points[1][0])
            return k1 != k2
"""
https://leetcode.com/problems/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


Note:

points.length == 3
points[i].length == 2
0 <= points[i][j] <= 100
"""

# time complexity: O(1), space complexity: O(1)

class Solution:
    def isBoomerang(self, points: List[List[int]]) -> bool:
        s = set()
        for a,b in points:
            s.add((a,b))
        if len(s) < 3:
            return False
        if points[0][0] == points[1][0] == points[2][0]:
            return False
        elif points[0][0] == points[1][0] or points[0][0] == points[2][0] or points[1][0] == points[2][0]:
            return True
        else:
            k1 = (points[1][1]-points[0][1]) / (points[1][0]-points[0][0])
            k2 = (points[2][1]-points[1][1]) / (points[2][0]-points[1][0])
            return k1 != k2
https://leetcode.com/problems/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   Note:  points.length == 3 points[i].length == 2 0 <= points[i][j] <= 100 # time complexity: O(1), space complexity: O(1)