Question: NEED PSEUDOCODE FOR THIS CODING package disktower; import java.util.*; class MyComparator implements Comparator { public int compare(Object obj1,Object obj2) { Integer i1=(Integer)obj1; Integer i2=(Integer)obj2; return
NEED PSEUDOCODE FOR THIS CODING
package disktower;
import java.util.*;
class MyComparator implements Comparator
{
public int compare(Object obj1,Object obj2)
{
Integer i1=(Integer)obj1;
Integer i2=(Integer)obj2;
return i2.compareTo(i1);
}
}
public class DiskTower
{
public static void main(String[] args)
{
Scanner sc=new Scanner(System.in);
int n=sc.nextInt();
int max=n;
Queue
int disks[]=new int[n];
for(int i=0;i { disks[i]=sc.nextInt(); queue.add(disks[i]); while(!queue.isEmpty() && queue.peek()==max) { System.out.print(queue.poll() + " "); max--; } System.out.println(); } } }
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
