Académique Documents
Professionnel Documents
Culture Documents
package bravearray;
import java.util.*;
public class BraveArray
{
public static void main(String[] arg)
{
Scanner sc=new Scanner(System.in);
int n=sc.nextInt();
int flag=-1;
int[] ar=new int[n];
for(int i=0;i<n;i++)
ar[i]=sc.nextInt();
int cnt=0,tcnt=0;
for(int i=0;i<n-1;i++)
{
if(ar[i]<ar[i+1])
{
if(flag==1)
{
tcnt++;
}
else if(flag==0 | flag==-1)
{
flag=1;
cnt=cnt<tcnt?tcnt:cnt;
tcnt=2;
}
}
else
{
if(flag==1 |flag ==-1)
{
flag=0;
cnt=cnt<tcnt?tcnt:cnt;
tcnt=2;
}
else
tcnt++;
}
}
System.out.println(cnt);
}
}
SherlockArray:
package sherlockarray;
import java.util.Scanner;
}
if(flag)
System.out.println("Yes");
else
System.out.println("No");
}
EqualStacks:
/*
* To change this license header, choose License Headers in Project Properties.
* To change this template file, choose Tools | Templates
* and open the template in the editor.
*/
package equalstack;
import java.util.Scanner;
Balance brackets:
/*
* To change this license header, choose License Headers in Project Properties.
* To change this template file, choose Tools | Templates
* and open the template in the editor.
*/
package balancedbrackets;
/**
*
* @author 101874
*/
import java.util.*;
public class BalancedBrackets {
Save Prisoner:
package savePrisoner;
import java.util.*;
public class SavePrisoner {
}
Balanced Brackets
/*
* To change this license header, choose License Headers in Project Properties.
* To change this template file, choose Tools | Templates
* and open the template in the editor.
*/
package balancedbrackets;
/**
*
* @author 101874
*/
import java.util.*;
public class BalancedBrackets {