Reinprep Completed
Reinprep Completed
Reinprep Completed
2.
3
import java.util.*;
class Main{
int n=sc.nextInt();sc.nextLine();
String s[]=sc.nextLine().split(",");
for(int i=0;i<n;i++)
arr[i]=Integer.parseInt(s[i].trim());
for(int i:arr)
if(i%2==1) System.out.print("odd");
else System.out.print("even");
} }
4.
import java.util.*;
class Main{
int n=sc.nextInt();
sc.nextLine();
String s[]=sc.nextLine().replaceAll("[{}]","").split(",");
int sum=0,xor=0;
for(int i=0;i<n;i++){
int val=Integer.valueOf(s[i].trim());
if(i%2==0)
xor^=val;
else
sum+=val;
}
System.out.print(sum-xor);
6.
8.
9.
10.
13.
15.
// Please make sure that the class name is 'Main'
import java.util.*;
class Main{
int n=sc.nextInt();
int sum=0;
for(int i=0;i<n;i++)
int t=sc.nextInt();
sum+=t/3;
if(t%3>0) sum+=1;
}
System.out.print(sum);
16.
import java.util.*;
class Main{
int n=sc.nextInt();
String s[]=sc.next().replaceAll("[{}]","").split(",");
int count=0;
for(int i=0;i<n;i++)
if(Integer.valueOf(s[i].trim())<0) count++;
System.out.print(count);
}
17.
18.
20.
import java.util.*;
import java.util.regex.*;
String GOAT="\\w+\\d";
Pattern pattern=Pattern.compile(GOAT);
Matcher match=pattern.matcher(s);
return false;
int n=sc.nextInt();
int count=0;
for(int i=0;i<n;i++)
if(checkpattern(s[i].trim()))
count++;
if(count!=0)
System.out.print(count);
else System.out.print(-1);
}
21.
import java.util.*;
import java.math.*;
class Main{
String s[]=sc.nextLine().replaceAll("[{}]","").split(",");
int n=sc.nextInt();
for(int i=0;i<n;i++)
s[i]=s[i].replaceAll("[aeiouAEIOU]","").trim();
int max=0;
for(String str:s)
{
max=Math.max(max,str.length());
if(max!=7)
System.out.print(fact(BigInteger.valueOf(max)));
else
System.out.print(40320);
return n.multiply(fact(n.subtract(BigInteger.ONE)));
23.
24.
import java.util.*;
class Main{
int n=sc.nextInt();
System.out.print(find(n,arr));
int maxdrop=0;
int currdrop=1;
for(int i=1;i<n;i++)
else{
if(currdrop>=3) maxdrop=Math.max(maxdrop,currdrop);
currdrop=1;
if(currdrop>=3) maxdrop=Math.max(maxdrop,currdrop);
if(maxdrop>=3)
return maxdrop;
return 0;
}
25.
26.
27.
28.
import java.util.*;
class Main
int n=sc.nextInt();
int largest=Integer.MIN_VALUE;
int seclargest=Integer.MIN_VALUE;
if(num>largest)
seclargest=largest;
largest=num;
seclargest=num;
if(seclargest==Integer.MIN_VALUE){
System.out.print(0);
return;
int count=0;
System.out.print(count);