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

&nbsp;

&nbsp;
Example 1:



Input: coordinates = [[1,2],[2,3],[3,4],[4,5],[5,6],[6,7]]
Output: true


Example 2:



Input: coordinates = [[1,1],[2,2],[3,4],[4,5],[5,6],[7,7]]
Output: false


&nbsp;
Constraints:


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

class Solution(object):
    def checkStraightLine(self, coordinates):
        """
        :type coordinates: List[List[int]]
        :rtype: bool
        """
        if len(coordinates) == 2:
            return True
        
        num = coordinates[1][1] - coordinates[0][1]
        den = coordinates[1][0] - coordinates[0][0]
        
        for i in range(2, len(coordinates)):
            if num * (coordinates[i][0] - coordinates[0][0]) != den * (coordinates[i][1] - coordinates[0][1]):
                return False
        
        return True
class Solution {
    public boolean checkStraightLine(int[][] coordinates) {
        int x1=coordinates[0][0];
        int y1=coordinates[0][1];
        
        int x2=coordinates[1][0];
        int y2=coordinates[1][1];
        
        float slope;
        if(x2-x1 == 0)
        {
            slope=Integer.MAX_VALUE;
        }
        else
        {
            slope=(y2-y1)/(float)(x2-x1);
        }
        for(int i=0;i<coordinates.length;i++)
        {
            for(int j=0;j<2;j++)
            {
                if(slope==Integer.MAX_VALUE)
                {
                    if(coordinates[i][0]!=x1)
                        return false;
                }
                else
                {
                    int y=coordinates[i][1];
                    int x=coordinates[i][0];
                    if((float)(y-y1) != slope*(x-x1))
                        return false;
                }
                    
            }
        }
        return true;
    }
}
class Solution {
public:
    bool checkStraightLine(vector<vector<int>>& coordinates) {
        
        int n=coordinates.size();  
        int xdiff = coordinates[1][0] - coordinates[0][0]; 
        int ydiff = coordinates[1][1] - coordinates[0][1];
        
        int cur_xdiff, cur_ydiff;
        
        for(int i=2; i<n; i++){
            
            cur_xdiff = coordinates[i][0] - coordinates[i-1][0];
            cur_ydiff = coordinates[i][1] - coordinates[i-1][1];
            
            if(ydiff*cur_xdiff!=xdiff*cur_ydiff) return false;
        }
        return true;
    }
};
var checkStraightLine = function(coordinates) {
    coordinates.sort((a, b) => a[1] - b[1])
    
    let slopeToCheck = (coordinates[1][1] - coordinates[0][1]) / (coordinates[1][0] - coordinates[0][0])
    
    for (let i = 2; i < coordinates.length; i++) {
        let currSlope = (coordinates[i][1] - coordinates[i - 1][1]) / (coordinates[i][0] - coordinates[i - 1][0]);
        
        if (currSlope !== slopeToCheck) return false;
    }
    
    return true;
};
Check If It Is a Straight Line