public static boolean f(byte[] x, int a, int b) {
if (a < b) {
if (x[a] != x[b]) {
return false;
}
return f(x, ++a, --b);
}
return true;
}test:
String s = "abcba";
if (f(s.getBytes(), 0, s.length() - 1)) {
System.out.println("yes");
}不支持中文
if (a < b) {
if (x[a] != x[b]) {
return false;
}
return f(x, ++a, --b);
}
return true;
}test:
String s = "abcba";
if (f(s.getBytes(), 0, s.length() - 1)) {
System.out.println("yes");
}不支持中文
解决方案 »
免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货