leetcode Valid Palindrome
来源:互联网 发布:origin软件怎么安装 编辑:程序博客网 时间:2024/06/08 00:26
题目:https://oj.leetcode.com/problems/valid-palindrome/
字符是字母和数字构成回文的就是回文字符串
那把不是字母和数字的字符剔除。
在用最笨的方法判断是不是回文。
public class Solution { public boolean isPalindrome(String s) { if(s==null||s.length()==1||s.equals(""))return true; char[]chars=s.toCharArray(); StringBuffer str=new StringBuffer(); for(char temp:chars){ if(Character.isLetter(temp)||Character.isDigit(temp)){ str.append(temp); } } String string=str.toString().toLowerCase(); if(string.length()<=1)return true; int len=string.length(); for(int i=0;i<=len/2;i++){ if(string.charAt(i)==string.charAt(len-1-i)){ continue; }else return false; } return true; }}
0 0
- [Leetcode] Valid Palindrome
- Leetcode: Valid Palindrome
- leetcode 55: Valid Palindrome
- [LeetCode] Valid Palindrome
- 【leetcode】Valid Palindrome
- LeetCode - Valid Palindrome
- [leetcode]Valid Palindrome
- [LeetCode]Valid Palindrome
- [Leetcode]Valid Palindrome
- LeetCode-Valid Palindrome
- [leetcode] Valid Palindrome
- LeetCode 125: Valid Palindrome
- LeetCode - Valid Palindrome
- leetcode之Valid Palindrome
- LeetCode | Valid Palindrome
- [leetcode]Valid Palindrome
- 【leetcode】Valid Palindrome
- LeetCode题解:Valid Palindrome
- 查看Linux并发连接数
- 3Sum Closest
- 用图片实现form表单的提交按钮
- 函数指针及其的运用(上)——何为函数指针
- Gulp 自动化的项目构建工具
- leetcode Valid Palindrome
- Nand Flash,Nor Flash,CFI Flash,SPI Flash 之间的关系
- cocos2d-x error C2143: 语法错误 : 缺少“;”(在“*”的前面)
- Linux 指令详解 pushd 快速切换目录
- canvas.drawText 发生 Fatal signal 11 (SIGSEGV) at 0x00000000 (code=1)
- JAVA集合类--给面试的TX们
- jQuery.tablesorter html表格排序插件
- 欢迎使用CSDN-markdown编辑器
- Android系统回顾(五):Android Application类