import java.util.*;
public class Main {
public static void main(String args[]) {
Scanner sc = new Scanner(System.in);
int n = sc.nextInt();
int [] arr = new int[n];
for(int i=0;i<arr.length;i++)
{
arr[i] = sc.nextInt;
}
Stack stack = new Stack<>();
for(int i=0; i<=arr.length-1;i++)
{
while(!stack.isEmpty() && arr[i]>stack.peek())
{
int rv = stack.pop();
System.out.print(arr[i]+" β);
}
stack.push(arr[i]);
}
if(!stack.isEmpty())
{
int rv = stack.pop();
System.out.print(β-1"+" ");
}
}
}
i donβt know which its not comipling
help ASAP
Find the greotor element challaenge
Hey @Naman_Gupta
Compilation error has been removed.
but your code is Not working
5
4 2 3 1 0
correct Output : -1 3 4 4 4
Your code Gives : 3 -1