Dear supercoders,
can anyone tell why i getting wronganswer while submitting, instead of getting correct output with every testcase.plzzz provide details of why i getting this problem.
I getting accurate answer in online java compiler also.
AND MY SOLUTION LINK AS FOLLOWS
Https://www.codechef.com/viewsolution/24116425
AND MY CODE IS AS FOLLOWS
import java.util.;
import java.lang.;
import java.io.*;
/* Name of the class has to be “Main” only if the class is public. */
class Codechef
{
public static void main (String[] args) throws java.lang.Exception
{
try{
int N,i,j,k,smpl,val=0,fnlval=0;
String str;
Scanner sc=new Scanner(System.in);
// System.out.println(“enter size”);
N=sc.nextInt();
sc.nextLine();
StringBuffer sb=new StringBuffer(N);
str=sc.nextLine();
sb.append(str);
//len=sb.length();
for(i=N-1,j=0;i>=0;i–,j++)
{
char c=sb.charAt(i);
smpl=Character.getNumericValue(c);
// System.out.println("smpl is "+smpl);
val=val+((int)Math.pow(2,j)*smpl);
//System.out.println(" inside val is "+val);
}
// System.out.println("val is "+val);
for(i=N-1,j=0;i>=0;i--,j++)
{
if((j>fnlval)&&(val%(int)Math.pow(2,j)==0))
{
fnlval=j;
//System.out.println(" inside fnlval is "+fnlval);
}
}
System.out.println(fnlval);
// System.out.println("2power5 "+(int)Math.pow(2,5));
//System.out.println("Sum of x+y = " + z);
}catch(Exception e){return;}
}
}