What is wrong in my code?

import java.util.*;
public class Main {
public static void main(String args[]) {
Scanner scn = new Scanner(System.in);
int n = scn.nextInt();

	int [] arr =new int [n];
	for (int i=0;i<n;i++) {
		arr[i]=scn.nextInt();
	}
	
    Stack<Integer> stack=new Stack<>();
    
    for (int i=0;i<arr.length;i++) {
    	while (!stack.isEmpty() && arr[i]>stack.peek()) {
    		int rv=stack.pop();
    		
    		System.out.print(arr[i]+" ");
    	}
    	
    	stack.push(arr[i]);
    }
    
    while(!stack.isEmpty()) {
    	stack.pop();
    	System.out.print("-1"+" ");
    }
    
    




}

}

@harsh.hj Hi bro, two problems in ya code!

  • We are given a circular array
  • The order is not maintained so just take an array to maintain the order.

You will be good to go.
Happy Coding!

can u send me the corrected code???