Leetcode 1349 Solution

This article provides solution to leetcode question 1349 (check-if-it-is-a-straight-line)

https://leetcode.com/problems/check-if-it-is-a-straight-line

Solution

class Solution: def checkStraightLine(self, coordinates: List[List[int]]) -> bool: for i in range(2, len(coordinates)): x1 = coordinates[0][0] y1 = coordinates[0][1]
x2 = coordinates[1][0] y2 = coordinates[1][1]
x3 = coordinates[i][0] y3 = coordinates[i][1]
if (y2 - y1) * (x3 - x1) != (y3 - y1) * (x2 - x1): return False return True