package leetcode;

/**
 * https://leetcode.com/problems/check-if-it-is-a-straight-line/
 */
public class Problem1232 {
    public boolean checkStraightLine(int[][] coordinates) {
        // TODO
        return false;
    }

    public static void main(String[] args) {
        Problem1232 prob = new Problem1232();
        System.out.println(prob.checkStraightLine(new int[][]{
            {1, 2}, {2, 3}, {3, 4}, {4, 5}, {5, 6}, {6, 7}
        })); // true
        System.out.println(prob.checkStraightLine(new int[][]{
            {1, 1}, {2, 2}, {3, 4}, {4, 5}, {5, 6}, {7, 7}
        })); // false
    }
}

@@ -184,422 +184,615 @@
     
-// TODO%0A        return false;
+for (int i = 0; i %3C coordinates.length - 2; i++) %7B
 %0A    
-%7D%0A%0A
+ 
     
-public static void main(String%5B%5D args) %7B%0A        Problem1232 prob = new Problem1232();%0A        System.out.println(prob.checkStraightLine(new int%5B%5D%5B%5D%7B%0A            %7B1, 2%7D, %7B2, 3%7D, %7B3, 4%7D, %7B4, 5%7D, %7B5, 6%7D, %7B6, 7%7D%0A        %7D)); //
+   if (!isColiner(%0A                coordinates%5Bi%5D%5B0%5D, coordinates%5Bi%5D%5B1%5D,%0A                coordinates%5Bi + 1%5D%5B0%5D, coordinates%5Bi + 1%5D%5B1%5D,%0A                coordinates%5Bi + 2%5D%5B0%5D, coordinates%5Bi + 2%5D%5B1%5D)) %7B%0A                return false;%0A            %7D%0A        %7D%0A        return
  true
+;
 %0A    
+%7D%0A%0A
     
-System.out.println(prob.checkS
+private static boolean isColiner(int x1, int y1, int x2, int y2, int x3, int y3) %7B%0A        // https://math.stackexchange.com/questions/701862/how-to-find-if-the-points-fall-in-a-s
 traight
-Line(new int%5B%5D%5B%5D%7B%0A            %7B1, 1%7D, %7B2, 2%7D, %7B3, 4%7D, %7B4, 5%7D, %7B5, 6%7D, %7B7, 7%7D%0A        %7D)); // false
+-line-or-not%0A        return (y2 - y1) * (x3 - x1) == (y3 - y1) * (x2 - x1);
 %0A   

Solve problem 1232