http://oj.leetcode.com/problems/valid-palindrome/

判断是否为回文串

  1. bool isPalindrome(string s) {
  2. int i = ,j = s.length() -;
  3. int flag = ;
  4.  
  5. if(s=="")
  6. return true;
  7.  
  8. while(i<=j)
  9. {
  10. while(!('a'<= s[i] && s[i]<= 'z' || 'A' <= s[i] && s[i] <='Z' || s[i]>= ''&&s[i]<='') || s[i] == ' ' )
  11. {
  12. if(i== s.length())
  13. break;
  14. i++;
  15. }
  16. while(!('a'<= s[j] && s[j]<= 'z' || 'A' <= s[j] && s[j] <='Z' || s[j]>= ''&&s[j]<='') || s[j] == ' ')
  17. {
  18. if(j==)
  19. break;
  20. j--;
  21. }
  22. if(toupper(s[i]) != toupper(s[j]) && i<=j)
  23. {
  24. flag = ;
  25. break;
  26. }
  27. i++;
  28. j--;
  29. }
  30. if(flag == )
  31. return false;
  32. else
  33. return true;
  34. }

LeetCode OJ--Valid Palindrome的更多相关文章

  1. [LeetCode] 680. Valid Palindrome II 验证回文字符串 II

    Given a non-empty string s, you may delete at most one character. Judge whether you can make it a pa ...

  2. [Leetcode][JAVA] Valid Palindrome

    Given a string, determine if it is a palindrome, considering only alphanumeric characters and ignori ...

  3. [leetcode] 1. Valid Palindrome

    leetcode的第一题,回文数判断. 原题如下: For example, "A man, a plan, a canal: Panama" is a palindrome. & ...

  4. LeetCode 1216. Valid Palindrome III

    原题链接在这里:https://leetcode.com/problems/valid-palindrome-iii/ 题目: Given a string s and an integer k, f ...

  5. [LeetCode] 125. Valid Palindrome 验证回文字符串

    Given a string, determine if it is a palindrome, considering only alphanumeric characters and ignori ...

  6. 【leetcode】Valid Palindrome

    题目简述: Given a string, determine if it is a palindrome, considering only alphanumeric characters and ...

  7. 【题解】【字符串】【Leetcode】Valid Palindrome

    Given a string, determine if it is a palindrome, considering only alphanumeric characters and ignori ...

  8. leetcode 125. Valid Palindrome ----- java

    Given a string, determine if it is a palindrome, considering only alphanumeric characters and ignori ...

  9. LeetCode 125. Valid Palindrome

    这个题目只要注意大小写问题即可解决,而且我们只关注的是字母和数值 Given a string, determine if it is a palindrome, considering only a ...

  10. leetcode:Valid Palindrome

    Given a string, determine if it is a palindrome, considering only alphanumeric characters and ignori ...

随机推荐

  1. C-基础:详解sizeof和strlen,以及strstr

    sizeof和strlen (string.h) 先看几个例子(sizeof和strlen之间的区别):  (1) 对于一个指针, char* ss ="0123456789"; ...

  2. oracle中group by的高级用法

    简单的group by用法 select c1,sum(c2) from t1 where t1<>'test' group by c1 having sum(c2)>100; ro ...

  3. Quartz监听的端口

    上海移通短信网关:556重庆移动短信网关:557消息中心后台维护服务:558网页订单数据同步服务:559基础数据同步程序:560短信数据扣除服务:565基础数据维护服务:589推送数据抓取服务:222 ...

  4. 【树状数组 离散化】bzoj1573: [Usaco2009 Open]牛绣花cowemb

    解方程题! Description Bessie学会了刺绣这种精细的工作.牛们在一片半径为d(1 <= d <= 50000)的圆形布上绣花. 它们一共绣了N (2 <= N < ...

  5. ZJOI2018游记Round2

    Day0 趁着空档还溜回班上了一节物理课:瓢泼之中在9:00赶往余姚,车程3h+-- 中饭在一家饭馆,味道海星. 晚上和ykh,chj,xzt溜去吃一鸣和烧烤.一鸣不错,烧烤的话我因为口腔溃疡没怎么吃 ...

  6. 纯 CSS 创作一个表达怀念童年心情的条纹彩虹心特效

    效果预览 在线演示 按下右侧的"点击预览"按钮可以在当前页面预览,点击链接可以全屏预览. https://codepen.io/comehope/pen/QxbmxJ 可交互视频教 ...

  7. verilog behavioral modeling--branch statement

    conditional statement case statement 1. conditional statement     if(expression)         statement_o ...

  8. linux定时任务执行php任务

    首先用命令检查服务是否在运行 systemctl status crond.service 如果服务器上没有装有crontab ,则可以执行 yum install vixie-cron yum in ...

  9. boot_mem分配器

    #define alloc_bootmem_low_pages(x) \ __alloc_bootmem_low(x, PAGE_SIZE, ) void * __init __alloc_bootm ...

  10. Makefile文件中的sed介绍

    haoxin$ sed --helpUsage: sed [OPTION]... {script-only-if-no-other-script} [input-file]... -n, --quie ...