import java.util.*;
public class MainAssignment3
{
public static void main(String[]args)
{
int Max =0;
int Value =0;
LinkedList<Integer>Input=new LinkedList<Integer>();
LinkedList<Integer>Temp=new LinkedList<Integer>();
LinkedList<Integer>OutPut=new LinkedList<Integer>();
Input.addLast(90);
Input.addLast(21);
Input.addLast(33);
Input.addLast(80);
Input.addLast(67);
System.out.println("The Input Stack is : " + Input);
while(!Input.isEmpty())
{
Max = (Integer)Input.removeLast();
Value = (Integer)Input.removeLast();
System.out.println("MAx: " +Max);
System.out.println("Value: " +Value);
if (Value < Max)
{
Temp.addLast(Max);
Max=Value;
} else {
Temp.addLast(Value);
}
Input = Temp;
OutPut.addLast(Max);
Temp.clear();
System.out.println(OutPut);
}
}
}
Input Stack should is [90, 21, 33, 80, 67]
OutPut Stack Should is [21, 33, 67, 80 ,90]
But i Only Get [67]
any solution help ?