1 test case is not passing

in this stack span ques my 1 test case is not passing can anyone please help me, if there is any corner case that I am leaving.Or anything else to pass the 3rd test case

hey @anubhav_mishra
Try for this input :
5
30
40
35
45
42
correct output : 1 2 1 4 1 END

After correcting for this now 2nd test case is not working which was working earlier

import java.util.*;
import java.util.Stack;

public class Main {

	public static void main(String[] args) {
		// TODO Auto-generated method stub
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		int count=2,num =0;
		Stack<Integer> stack = new Stack<Integer>();
		
		for(int i=0;i<n;i++) {
			num = sc.nextInt();
			
			if(!stack.isEmpty()) {
				
				if(stack.size()==1) {
					//System.out.println();
					System.out.print(2+" ");
					stack.push(num);
					continue;
				}
				
				if(stack.peek()<=num) {
					count++;
					System.out.print(count+" ");
				}
				else {
					System.out.print(1+" ");
					count++;
				}

			}
			if(stack.isEmpty()) {
				System.out.print(1+" ");
			}
			stack.push(num);
		}
		
		
		System.out.println("END");

	}

}

@anubhav_mishra
5
39
45
40
42
43
correct output : 1 2 1 2 3 END

I think I am not able to understand the question properly can you please explain it

The span Si of the stock’s price on a given day i is defined as the maximum number of consecutive days just before the given day, for which the price of the stock on the current day is less than or equal to its price on the given day.
For example, if an array of 7 days prices is given as {100, 80, 60, 70, 60, 75, 85}, then the span values for corresponding 7 days are {1, 1, 1, 2, 1, 4, 6}

For computing this problem we will use stack data structure. Time complexity of this method is O(N) where N is the size of stock price array.
In this method S[i] (stock span value) on day i can be easily computed if we know the closest day preceding i, such that the price is greater than on that day than the price on day i.
you can refer this