Whats wrong in this, same code runs in local with expected result


#1

public class Solution {
static int position = 0;
public int solve(String A) {
int l = A.length();
int flag = 0;
int count =0;
while(l>0){
if(isPalindrome(A)){
flag=1;
break;
}
else{
count++;
A=A.substring(0,position)+A.substring(position+1,A.length()-1-position)+A.substring(A.length()-1-position+1,A.length());
position=0;
}
}
if(count==1){
return 1;
}
else{
return 0;
}
}
static boolean isPalindrome(String s){
for(int i=0,j=s.length()-1;i<=j;i++,j–){
if(s.charAt(i)!=s.charAt(j)){
return false;
}
position++;
}
return true;
}
}