string - Leetcode 125 为什么会失败
问题描述
我的代码如下:当输入是“一个人,一个计划,一条运河:巴拿马”时,我得到了错误,这是错误的。谁能告诉我为什么?谢谢!
class Solution {
public boolean isPalindrome(String s) {
String fixedS = "";
for(char a: s.toCharArray()){
if(Character.isLetter(a) || Character.isDigit(a)){
fixedS += a;
}
fixedS = fixedS.toLowerCase();
int start = 0;
int end = fixedS.length()-1;
while(start <= end){
if(fixedS.charAt(start) != fixedS.charAt(end)){
return false;
}
start++;
end--;
}
}return true;
}
}
解决方案
推荐阅读
- python - 使用 ctypes 将十六进制值从 C Dll 返回到 Python
- mysql - MySQL左连接计数未显示左表中的所有条目
- python - 坚持一个大 scipy.sparse.csr_matrix
- node.js - Heroku + MERN 堆栈 - 任何值的 HTTP POST 请求无效
- c# - 在 C# 的 WinPE10 中接收 WM_QueryEndSession 或 WM_WTSSESSIONCHANGE
- javascript - dataTables - 如何使所有列在“draw.dt”上可排序
- javascript - 排队回调函数然后等待它们的执行
- python - 在 scipy.spatial.Delaunay python 中找到一个点的所有单纯形
- jekyll - 如何在带有 Liquid 模板语言的 if 语句中使用 for 循环?
- r - R/Shiny 直方图类作为反应性