题解 |判断回文串
判断回文
http://www.nowcoder.com/practice/e297fdd8e9f543059b0b5f05f3a7f3b2
双指针
import java.util.*;
public class Solution {
public boolean judge (String str) {
// write code here
int left = 0, right = str.length() - 1;
while (left < right){
if (str.charAt(left) != str.charAt(right)){
return false;
}
left++;
right--;
}
return true;
}
}
查看1道真题和解析
