@@ -0,0 +1,1764 @@
+# Time:  O(n)%0A# Space: O(1)%0A%0A# You are playing a simplified Pacman game.%0A# You start at the point (0, 0), and your destination is (target%5B0%5D, target%5B1%5D).%0A# There are several ghosts on the map, the i-th ghost starts at (ghosts%5Bi%5D%5B0%5D, ghosts%5Bi%5D%5B1%5D).%0A#%0A# Each turn, you and all ghosts simultaneously *may* move%0A# in one of 4 cardinal directions: north, east, west, or south,%0A# going from the previous point to a new point 1 unit of distance away.%0A#%0A# You escape if and only if you can reach the target before any ghost%0A# reaches you (for any given moves the ghosts may take.)%0A# If you reach any square (including the target) at the same time as a ghost,%0A# it doesn't count as an escape.%0A#%0A# Return True if and only if it is possible to escape.%0A#%0A# Example 1:%0A# Input: %0A# ghosts = %5B%5B1, 0%5D, %5B0, 3%5D%5D%0A# target = %5B0, 1%5D%0A# Output: true%0A# Explanation: %0A# You can directly reach the destination (0, 1) at time 1,%0A# while the ghosts located at (1, 0) or (0, 3) have no way to catch up with you.%0A#%0A# Example 2:%0A# Input: %0A# ghosts = %5B%5B1, 0%5D%5D%0A# target = %5B2, 0%5D%0A# Output: false%0A# Explanation: %0A# You need to reach the destination (2, 0), but the ghost at (1, 0) lies between you and the destination.%0A# Example 3:%0A# Input: %0A# ghosts = %5B%5B2, 0%5D%5D%0A# target = %5B1, 0%5D%0A# Output: false%0A# Explanation: %0A# The ghost can reach the target at the same time as you.%0A#%0A# Note:%0A# - All points have coordinates with absolute value %3C= 10000.%0A# - The number of ghosts will not exceed 100.%0A%0Aclass Solution(object):%0A    def escapeGhosts(self, ghosts, target):%0A        %22%22%22%0A        :type ghosts: List%5BList%5Bint%5D%5D%0A        :type target: List%5Bint%5D%0A        :rtype: bool%0A        %22%22%22%0A        total = abs(target%5B0%5D)+abs(target%5B1%5D)%0A        return all(total %3C abs(target%5B0%5D-i)+abs(target%5B1%5D-j) for i, j in ghosts)%0A

Create escape-the-ghosts.py