aboutsummaryrefslogtreecommitdiffstats
path: root/1496
diff options
context:
space:
mode:
authorterminaldweller <devi@terminaldweller.com>2023-12-23 03:54:00 +0000
committerterminaldweller <devi@terminaldweller.com>2023-12-23 03:54:00 +0000
commit3738c49630e2a3447a1d80e465964af5deb7caa1 (patch)
tree34d2d752b9b0587561b9ad481c997da7625774bb /1496
parent1422 (diff)
downloadleetcode-3738c49630e2a3447a1d80e465964af5deb7caa1.tar.gz
leetcode-3738c49630e2a3447a1d80e465964af5deb7caa1.zip
1496
Diffstat (limited to '1496')
-rwxr-xr-x1496/main.py31
1 files changed, 31 insertions, 0 deletions
diff --git a/1496/main.py b/1496/main.py
new file mode 100755
index 0000000..e708e0c
--- /dev/null
+++ b/1496/main.py
@@ -0,0 +1,31 @@
+#!/usr/bin/env python
+
+
+class Solution:
+ def isPathCrossing(self, path: str) -> bool:
+ x = 0
+ y = 0
+ visited = set()
+ visited.add((x, y))
+ for i in path:
+ if i == "N":
+ y += 1
+ elif i == "S":
+ y -= 1
+ elif i == "E":
+ x += 1
+ else:
+ x -= 1
+ if (x, y) in visited:
+ return True
+ visited.add((x, y))
+ return False
+
+
+def main():
+ solution = Solution()
+ print(solution.isPathCrossing("NES"))
+
+
+if __name__ == "__main__":
+ main()