2025-08-02 13:11:25 +0000 UTC

Check If It Is a Straight Line

Code

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