🔥Beats 100% | Most Easy Approach(Explained) 🔥
\n\n# Approach\n Describe your approach to solving the problem. \n- first calculate distance from origin to target\n\n- simply iterate through all coordinates(g
\n\n# Approach\n<!-- Describe your approach to solving the problem. -->\n- first calculate distance from origin to target\n\n- simply iterate through all coordinates(ghost locations) and find their distance from given target point(where we want to reach to escape)\n\n- if you find any point(ghost locations) whose distance is less than or equal to the distance of target from origin,in that case we can ghost will catch and we\'ll die so return 0\n\n- outside the loop we can simply return 1 denoting we get saved from ghost because we don\'t find any ghost nearer to target than our location to target place\n\n# Complexity\n- Time complexity:\nO(n)\n\n- Space complexity:\n O(1)\n\n# Code\n```\nclass Solution {\npublic:\n    bool escapeGhosts(vector<vector<int>>& ghosts, vector<int>& target) {\n     int tx=target[0];\n     int ty=target[1];\n     int dt=abs(ty)+abs(tx);\n     for(auto i:ghosts)\n     {\n         int d=abs(tx-i[0])+abs(ty-i[1]);\n         if(d<=dt)\n         {\n             return 0;\n         }\n     }   \n     return 1;\n    }\n};\n```
['C++']