pls correct my code its showing some error ???
Increasing Decreasing Sequence
can any one give me a code ?
is there any ta available ???
import java.util.Scanner;
public class DecreasingIncreasing {
public static void main(String[] args) {
Scanner sc=new Scanner(System.in);
int n=sc.nextInt();
int num=sc.nextInt();
int sign=0;
boolean isStrictlyDecIn=false;
int prev=num;
while (n-1>0)
{
num=sc.nextInt();
int present=num;
if(prev<present)
{
isStrictlyDecIn=true;
}
if(prev>present)
{
if(isStrictlyDecIn==true) {
isStrictlyDecIn = false;
sign=2;
}
if(sign!=2)
sign=1;
}
if(prev==present)
{
isStrictlyDecIn=false;
sign=2;
}
prev=num;
n--;
}
if(isStrictlyDecIn==true&&sign!=2)
System.out.println("true");
else
{
if(sign==2)
System.out.println("false");
else
System.out.println("true");
}
}
}
//My code is working please check it and if you find any difficulty in getting the logic let me know
I hope I’ve cleared your doubt. I ask you to please rate your experience here
Your feedback is very important. It helps us improve our platform and hence provide you
the learning experience you deserve.
On the off chance, you still have some questions or not find the answers satisfactory, you may reopen
the doubt.