<p>You are given an array&nbsp;<code>coordinates</code>, <code>coordinates[i] = [x, y]</code>, where <code>[x, y]</code> represents the coordinate of a point. Check if these points&nbsp;make a straight line in the XY plane.</p>

<p>&nbsp;</p>

<p>&nbsp;</p>
<p><strong class="example">Example 1:</strong></p>

<p><img alt="" src="https://assets.leetcode.com/uploads/2019/10/15/untitled-diagram-2.jpg" style="width: 336px; height: 336px;" /></p>

<pre>
<strong>Input:</strong> coordinates = [[1,2],[2,3],[3,4],[4,5],[5,6],[6,7]]
<strong>Output:</strong> true
</pre>

<p><strong class="example">Example 2:</strong></p>

<p><strong><img alt="" src="https://assets.leetcode.com/uploads/2019/10/09/untitled-diagram-1.jpg" style="width: 348px; height: 336px;" /></strong></p>

<pre>
<strong>Input:</strong> coordinates = [[1,1],[2,2],[3,4],[4,5],[5,6],[7,7]]
<strong>Output:</strong> false
</pre>

<p>&nbsp;</p>
<p><strong>Constraints:</strong></p>

<ul>
	<li><code>2 &lt;=&nbsp;coordinates.length &lt;= 1000</code></li>
	<li><code>coordinates[i].length == 2</code></li>
	<li><code>-10^4 &lt;=&nbsp;coordinates[i][0],&nbsp;coordinates[i][1] &lt;= 10^4</code></li>
	<li><code>coordinates</code>&nbsp;contains no duplicate point.</li>
</ul>

class Solution:
    def checkStraightLine(self, coordinates: List[List[int]]) -> bool:
        """
        slope formula: (y^2 - y^1) / (x^2 - x^1)
        only worry is that (x^2 - x^1) could equal zero which leads to an error

        to tackle this we can
        avoid divison through cross multiplicaiton 
        cross multiply: (y^2 - y^1) / (x^2 - x^1) = (y - y^1) / (x - x1)
        simplified: (y^2 - y^1) * (x - x1) (x^2 - x^1)*(y - y^1)
        if the slopes should give the same answer so if the numbers dont match then we've found
        a false case so we can immidiately return False

        we grab the two initial x1, y1 and x2, y2
        this is going to enable us to calculate the initial slope that shouldn't change
        iterate through the array pairs
        grabbing each x and y 

        performing our cross mutiplication

        if results dont match return False

        if we loop through everything we return True because we didnt find mismatched slopes
        """

        (x1, y1), (x2, y2) = coordinates[:2]

        for i in range(len(coordinates)):
            x, y = coordinates[i]
            if (y2 - y1) * (x - x1) != (x2 - x1)*(y - y1):
                return False
        return True
16700