Company: amazon_3march
Difficulty: medium
The developers at Amazon are working on fixing a bug where a HTTP request is being redirected to different servers. There are n servers are placed on a infinite 2D plane, each defined by their x and y coordinates, where the i th coordinate is represented by array locations[i] . Additionally, there are q redirectRecords that record the directions in which the requests were redirected, where the i th redirection is represented by redirectRecords[i] . The request is being redirected from one server (a, b) to another server in the following ways (Here, Z is an arbitrary positive integer, i.e., Z ≥ 1): Direction 1: (a, b) → (a + Z, b + Z). Direction 2: (a, b) → (a + Z, b - Z). Direction 3: (a, b) → (a - Z, b + Z). Direction 4: (a, b) → (a - Z, b - Z). The request is redirected to the nearest server present in the given direction, out of the 4 directions which have been specified above from the current server. The below rules are followed when the request is re-directed. If no servers exist