diff --git a/Java/nextgreater.java b/Java/nextgreater.java new file mode 100644 index 0000000..23f481c --- /dev/null +++ b/Java/nextgreater.java @@ -0,0 +1,43 @@ +import java.util.*; +class gre{ +public static void main(String[] args){ +Scanner sc=new Scanner(System.in); +int n=sc.nextInt(); +int a[]=new int[n]; +for(int i=0;i st=new Stack<>(); + + +for(int i: a){ + if(st.isEmpty()){ + st.add(i); + } + else{ while(!st.isEmpty()&&st.peek()"+i); + } + st.push(i); +} +} +while(!st.isEmpty()){ +System.out.println(st.pop()+"---"+"none"); + + +} + + + + +} + + + + + + + +} + +