LeetCode --- 1496. Path Crossing 解题报告
Posted 杨鑫newlfe
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了LeetCode --- 1496. Path Crossing 解题报告相关的知识,希望对你有一定的参考价值。
Given a string path
, where path[i] = \'N\'
, \'S\'
, \'E\'
or \'W\'
, each representing moving one unit north, south, east, or west, respectively. You start at the origin (0, 0)
on a 2D plane and walk on the path specified by path
.
Return true
if the path crosses itself at any point, that is, if at any time you are on a location you have previously visited. Return false
otherwise.
Example 1:
Input: path = "NES" Output: false Explanation: Notice that the path doesn\'t cross any point more than once.
Example 2:
以上是关于LeetCode --- 1496. Path Crossing 解题报告的主要内容,如果未能解决你的问题,请参考以下文章
Vijos P1496 火柴棒等式 NOIP2008提高组第二题