Skip to content

Commit 1d519cc

Browse files
refactor 1232
1 parent fd67521 commit 1d519cc

File tree

1 file changed

+1
-22
lines changed

1 file changed

+1
-22
lines changed

src/main/java/com/fishercoder/solutions/_1232.java

+1-22
Original file line numberDiff line numberDiff line change
@@ -1,26 +1,5 @@
11
package com.fishercoder.solutions;
22

3-
/**
4-
* 1232. Check If It Is a Straight Line
5-
*
6-
* You are given an array coordinates, coordinates[i] = [x, y],
7-
* where [x, y] represents the coordinate of a point.
8-
* Check if these points make a straight line in the XY plane.
9-
*
10-
* Example 1:
11-
* Input: coordinates = [[1,2],[2,3],[3,4],[4,5],[5,6],[6,7]]
12-
* Output: true
13-
*
14-
* Example 2:
15-
* Input: coordinates = [[1,1],[2,2],[3,4],[4,5],[5,6],[7,7]]
16-
* Output: false
17-
*
18-
* Constraints:
19-
* 2 <= coordinates.length <= 1000
20-
* coordinates[i].length == 2
21-
* -10^4 <= coordinates[i][0], coordinates[i][1] <= 10^4
22-
* coordinates contains no duplicate point.
23-
* */
243
public class _1232 {
254
public static class Solution1 {
265
/**
@@ -30,7 +9,7 @@ public static class Solution1 {
309
* considering denominator could be zero, we'll change it to use multiplication instead of division,
3110
* thus it becomes
3211
* check whether (y4 - y3)*(x2 - x1) equals (x4 - x3)*(y2 - y1)
33-
* */
12+
*/
3413
public boolean checkStraightLine(int[][] coordinates) {
3514
for (int i = 2; i < coordinates.length - 1; i++) {
3615
if ((coordinates[1][0] - coordinates[0][0]) * (coordinates[i + 1][1] - coordinates[i][1])

0 commit comments

Comments
 (0)