Problem
1232. Check If It Is a Straight Line
similar question
Java
my solution
1 | class Solution { |
Submission Detail
- 79 / 79 test cases passed.
- Runtime: 1 ms, faster than 22.67% of Java online submissions for Check If It Is a Straight Line.
- Memory Usage: 41 MB, less than 6.80% of Java online submissions for Check If It Is a Straight Line.
Computational geometry method
© Copyright 2002-2020, Robert Sedgewick and Kevin Wayne.
keys
- Shoelace formula, also known as Gauss’s area formula
- vertices must listed in clockwise(or counterclockwise, increasing order of polar angle) order
- CCW: Given three points a, b, and c, is a→b→c a counterclockwise turn? Determinant (or cross product) gives 2x signed area of planar triangle.
1 | import java.util.Comparator; |
Submission Detail
- 79 / 79 test cases passed.
- Runtime: 6 ms, faster than 9.07% of Java online submissions for Check If It Is a Straight Line.
- Memory Usage: 38.8 MB, less than 6.80% of Java online submissions for Check If It Is a Straight Line.