Answered step by step
Verified Expert Solution
Question
1 Approved Answer
NEED PSEUDOCODE FOR THIS CODING package stacks; import java.util.*; public class Stacks { /** * @param args the command line arguments */ public static void
NEED PSEUDOCODE FOR THIS CODING
package stacks;
import java.util.*;
public class Stacks {
/**
* @param args the command line arguments
*/
public static void main(String args[])
{
Scanner sc=new Scanner(System.in);
int n=sc.nextInt();
int array[]=new int[n];
for(int i=0;i array[i]=sc.nextInt(); int A=0,B=n-1; while(A<=B) { if(array[A]>array[B]) { System.out.print("1 "); B--; } else if(array[A] { System.out.print("2 "); A++; } else{ System.out.print("0 "); A++; B--; } } } }
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started