> For the complete documentation index, see [llms.txt](https://851958789.gitbook.io/notes/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://851958789.gitbook.io/notes/0335_self_crossing/slt.md).

# Solution 1 by cases

* t-complexity: $O(n)$
* s-complexity: %O(1)%

three cases that will not self crossing:

* always out: dist\[i] > dist\[i-2]
* always in: dist\[i] < dist\[i-2]
* first out then in:

see graph at: <https://leetcode-cn.com/problems/self-crossing/solution/tong-ge-lai-shua-ti-la-san-chong-bu-xian-w80r/>
