There are several cannons located on a plane. Each cannon is represented as a point, and can shoot in one of four directions: left, right, up or down. Given the coordinates of the cannons, assign a direction to each one such that no cannon shoots another cannon. Cannon A shoots cannon B if and only if B is located on A's line of fire. For example, if cannon A is located at (5,7) and cannon B is located at (9,7), cannon A cannot shoot to the right and cannon B cannot shoot to the left.
You are given the coordinates of the cannons in the ints x and y. The ith element of x is the x-coordinate of the ith cannon, and the ith element of y is the y-coordinate of the ith cannon. Return a String where the ith character is the direction assigned to the ith cannon. 'L' represents left, 'R' represents right, 'D' represents down, and 'U' represents up. If there is more than one valid return string, return the one that comes first alphabetically. If there is no possible arrangement, return the empty string.
|Method signature:||String getDirections(int x, int y)|
|(be sure your method is public)|
|-||Cannon A is located to the left(right) of the cannon B if and only if the y coordinates of A and B are equal and the x coordinate of A is less(greater) than the x coordinate of B.|
|-||Cannon A is located to the down(up) of the cannon B if and only if the x coordinates of A and B are equal and the y coordinate of A is less(greater) than the y coordinate of B.|
|-||x will contain between 1 and 50 elements, inclusive.|
|-||y will contain between 1 and 50 elements, inclusive.|
|-||x and y will contain the same number of elements.|
|-||Each element of x and y will be between -1000000 and 1000000, inclusive.|
|-||No two cannons will be located in the same point.|
|All cannons except for the third can shoot down. The third cannon can not shoot down, but can shoot right.|
|There is only one cannon here, so it can shoot in any direction. 'D' is chosen because it comes first alphabetically.|
|The second cannon is enclosed by the other cannons and cannot shoot in any of the four directions, so the empty string must be returned.|