For this Question: Given an sorted array <b>Arr[]</b> of size <b>N</b>, containing both <b>negative</b> and <b>positive</b> integers, you need to print the squared sorted output.

<b>Note</b> Try using two pointer approachThe first line of input contains T, denoting the number of test cases. Each testcase contains 2 lines. The first line contains the N size of the array. The second line contains elements of an array separated by space.

Constraints:
1 &le; T &le; 100
1 &le; N &le; 10000
-10000 &le; A[i] &le; 10000

The Sum of N over all test cases does not exceed 10^6For each test case you need to print the sorted squared output in new lineInput:
1
5
-7 -2 3 4 6

Output:
4 9 16 36 49, I have written this Solution Code: import java.util.*;
import java.io.*;
class Main
  {

	

	public static void main(String[] args)throws IOException {
		BufferedReader read = new BufferedReader(new InputStreamReader(System.in));
        int t = Integer.parseInt(read.readLine());

		while (t-- > 0) {

			int n = Integer.parseInt(read.readLine());
			int[] arr = new int[n];

            String str[] = read.readLine().trim().split(" ");
            for(int i = 0; i < n; i++)
            arr[i] = Integer.parseInt(str[i]);

            arr = sortedSquares(arr);
            
            for(int i = 0; i < n; i++)
               System.out.print(arr[i] + " ");
            System.out.println();
        }
    }
    public static int[] sortedSquares(int[] A) {
        int[] nums = new int[A.length];
        int k=A.length-1;
        int i=0, j=A.length-1;
        while(i<=j){
            if(Math.abs(A[i]) <= Math.abs(A[j])){
                nums[k--] = A[j]*A[j];
                j--;
            }
            else{
                nums[k--] = A[i]*A[i];
                i++;
            }    
        }
        return nums;
    }
}, In this Programming Language: Java, Now tell me if this Code is compilable or not?