How i can make the algorithm below more efficiently?
boolean isP(String s){
boolean bP = true;
for(int i=0; i<s.length(); i++){
if(s.charAt(i)!=s.charAt(s.length()-i-1)){
bP=false;
}
}
return bP;
}
I thought insert a
break;exaclty after
bP=false;, to terminate the algorithm, there is any better solution?
Thank you


Sign In
Create Account


Back to top









