For this Question: Given an array A, find the nearest smaller element S[i] for every element A[i] in the array such that the element has an index smaller than i.

More formally,
    S[i] for an element A[i] = an element A[j] such that 
    j is maximum possible AND 
    j < i AND
    A[j] <= A[i]
Elements for which no smaller element exist, consider next smaller element as -1.The first line contains the size of array, n
The next line n elements of the integer array, A[i]

<b>Constraints:</b>
1 <= n <= 10^5
1 <= A[i] <= 10^6Print the integer array S such that S[i] contains nearest smaller number than A[i] such than index of S[i] is less than 'i'. If no such element occurs S[i] should be -1.Input:
5
4 5 2 10 8

Output:
-1 4 -1 2 2

Explanation 1:
    index 1: No element less than 4 in left of 4, G[1] = -1
    index 2: A[1] is only element less than A[2], G[2] = A[1]
    index 3: No element less than 2 in left of 2, G[3] = -1
    index 4: A[3] is nearest element which is less than A[4], G[4] = A[3]
    index 4: A[3] is nearest element which is less than A[5], G[5] = A[3]

Input:
5
1 2 3 4 5

Output:
-1 1 2 3 4, I have written this Solution Code: import java.io.*; // for handling input/output
import java.util.*; // contains Collections framework

// don't change the name of this class
// you can add inner classes if needed
class Main {
	public static void main (String[] args) {
                      // Your code here

        Scanner sc = new Scanner(System.in);
        int arrSize = sc.nextInt();

        int arr[] = new int[arrSize];
        for(int i = 0; i < arrSize; i++)
           arr[i] = sc.nextInt();
           
        nearSmaller(arr, arrSize);
	}
    static void nearSmaller(int arr[], int arrSize)
    {
            Stack<Integer> s = new Stack<>();
        for(int i = 0; i < arrSize; i++)
        {
            
            while(!s.empty() == true && arr[s.peek()] > arr[i])
                s.pop();
            if(s.empty() == true)
               System.out.print(-1 +" ");
            else
                System.out.print(arr[s.peek()]+" ");
            s.push(i);
        }	
    }

}, In this Programming Language: Java, Now tell me if this Code is compilable or not?