Description

You are at origin, want to reach target. Ghosts try to catch you. All move 1 unit per step. Return true if you can reach target first.

Examples

Input:ghosts = [[1,0],[0,3]], target = [0,1]
Output:true
Explanation:

You reach first.

Input:ghosts = [[1,0]], target = [2,0]
Output:false
Explanation:

For ghosts = [[1,0]], target = [2,0], the answer is false because the escape the ghosts condition is not met.

Input:ghosts = [[2,2],[-1,4],[3,-2]], target = [1,1]
Output:true
Explanation:

You start at [0,0] and need 2 steps to reach [1,1]. Ghost at [2,2] needs 2 steps, ghost at [-1,4] needs 4 steps, and ghost at [3,-2] needs 5 steps. Since you tie with the closest ghost but reach simultaneously, you escape successfully.

Constraints

  • 1 ≤ ghosts.length ≤ 100

Ready to solve this problem?

Practice solo or challenge other developers in a real-time coding battle!