1
待完成
待完成
2
待完成
待完成
3
待完成
4
class Solution {
public int firstMatchingIndex(String s) {
int n = s.length();
for(int i = 0; i <= n / 2; i++){
if(s.charAt(i) == s.charAt(n - i - 1)){
return i;
}
}
return -1;
}
}
遍历i,下标取值范围[0,⌊n/2⌋],比较对称字符s[i] == s[n – i – 1],返回最小匹配下标。