For this Question: Given an array A of N integers. Return an array B of length N such that B<sub>1</sub> = (largest element of A + smallest element of A), B<sub>2</sub> = (2nd- largest element of A + 2nd- smallest element of A)......, B<sub>N</sub> = (N- th largest element of A + N- th smallest element of A)<b>User Task:</b>
Since this will be a functional problem, you don't have to take input. You just have to complete the function <b>solve()</b> that takes an integer N and an array A as parameters.

<b>Constraints</b>
1<=N<=1000
-10<sup>9</sup><=A<sub>i</sub><=10<sup>9</sup>Return an array of length N with its elements satisfying the given condition.Sample Input:
5
1 2 3 4 5

Sample Output:
6 6 6 6 6

We have B = {5+1, 2+4, 3+3, 4+2, 1+5} = {6, 6, 6, 6, 6}, I have written this Solution Code: 
class Solution {
    public long[] solve(int n, int[] arr) {
        long ans = 0;
        Arrays.sort(arr);
        int[] v = arr.clone();
        Arrays.sort(v);
        reverse(v);
        long[] x = new long[n];
        for (int i = 0; i < n; i++) {
            x[i] = v[i] + arr[i];
        }
        return x;
    }
    
    private void reverse(int[] arr) {
        int i = 0, j = arr.length - 1;
        while (i < j) {
            int temp = arr[i];
            arr[i] = arr[j];
            arr[j] = temp;
            i++;
            j--;
        }
    }
}
, In this Programming Language: Java, Now tell me if this Code is compilable or not?