public static int minLength( String s ) {
int len = s.length();
if ( s.indexOf( "a" )+s.indexOf( "b" )+s.indexOf( "c" ) == -2 )
return len;
String temp = "";
//判断字符串是否包含a、并将其替换为bc
if ( s.indexOf( "a" ) > -1 ){
temp = s.replaceAll( "a" , "bc" );
len = temp.length();
}
int bLen = temp.replaceAll( "b" , "" ).trim().length();
if (len % 2 == 0 && bLen % 2 == 0) return 2;
else return 1;
}
int len = s.length();
if ( s.indexOf( "a" )+s.indexOf( "b" )+s.indexOf( "c" ) == -2 )
return len;
String temp = "";
//判断字符串是否包含a、并将其替换为bc
if ( s.indexOf( "a" ) > -1 ){
temp = s.replaceAll( "a" , "bc" );
len = temp.length();
}
int bLen = temp.replaceAll( "b" , "" ).trim().length();
if (len % 2 == 0 && bLen % 2 == 0) return 2;
else return 1;
}