We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? # to your account
难度:简单 来源:125. 验证回文串
给定一个字符串,验证它是否是回文串,只考虑字母和数字字符,可以忽略字母的大小写。 回文串就是从左往右和从右往左的每个字符都是一样的。 说明:本题中,我们将空字符串定义为有效的回文串。
示例 1:
输入: "A man, a plan, a canal: Panama" 输出: true
示例 2:
输入: "race a car" 输出: false
思路:
题解:
/** * @param {string} s * @return {boolean} */ var isPalindrome = function(s) { if (!s) return true let arr = [...s.toLowerCase()].filter( item => 'a' <= item && item <= 'z' || '0' <= item && item <= '9') let left = 0, right = arr.length - 1 while(left <= right) { if ( arr[left] !== arr[right]) { return false } left++ right-- } return true };
The text was updated successfully, but these errors were encountered:
No branches or pull requests
验证回文串
难度:简单
来源:125. 验证回文串
给定一个字符串,验证它是否是回文串,只考虑字母和数字字符,可以忽略字母的大小写。
回文串就是从左往右和从右往左的每个字符都是一样的。
说明:本题中,我们将空字符串定义为有效的回文串。
示例 1:
示例 2:
思路:
题解:
The text was updated successfully, but these errors were encountered: