Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit 248d507

Browse files
Check If It Is a Straight Line
1 parent 9088dfd commit 248d507

File tree

1 file changed

+23
-0
lines changed

1 file changed

+23
-0
lines changed
Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
Link: https://leetcode.com/problems/check-if-it-is-a-straight-line/
2+
Language: C#
3+
4+
5+
6+
7+
8+
9+
10+
public class Solution {
11+
public bool CheckStraightLine(int[][] coordinates)
12+
{
13+
for (int i = 0; i < coordinates.Length - 2; i++)
14+
{
15+
if ((coordinates[i+2][1] - coordinates[i+1][1]) *
16+
(coordinates[i+1][0] - coordinates[i][0]) !=
17+
(coordinates[i+1][1] - coordinates[i][1]) *
18+
(coordinates[i+2][0] - coordinates[i+1][0]))
19+
return false;
20+
}
21+
return true;
22+
}
23+
}

0 commit comments

Comments
(0)

AltStyle によって変換されたページ (->オリジナル) /