aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-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()