Solved LeetCode program · 894 of 1,000
#1232 · Check If It Is a Straight Line
Original English source
The points is a list of 1, 1, 2, 2, 3, 4, 4, 5, 5, 6, 7, and 7. The firstx is item 0 of points. The firsty is item 1 of points. The secondx is item 2 of points. The secondy is item 3 of points. The valid is 1.
For every spot from 1 to 5.
The herex is item (spot times 2) of points. The herey is item (spot times 2 plus 1) of points. The along is (herex minus firstx) times (secondy minus firsty) minus (herey minus firsty) times (secondx minus firstx). If along is not 0, set valid to 0, stop.
If valid is 1, show true, otherwise show false.
Expected stdout
false