Valid Palindrome回文数

  whowhoha@outlook.com

Question:

Given a string, determine if it is a palindrome, considering only alphanumeric characters and ignoring cases. For example,

"A man, a plan, a canal: Panama" is a palindrome.

"race a car" is not a palindrome.

解决方法:使用两个指针,分别指向头尾,然后向中间移动依次判断

int isPalindrome(string s)

{

int i=0,j=s.size()-1;

if (j==0)

{

return 0;

}

while(i<j)

{

if (s[i++] != s[j--])

{

return 0;

}

}

return 1;

}

leetcode4 Valid Palindrome回文数的更多相关文章

  1. Palindrome 回文数

    回文数,从前到后,从后到前都一样 把数字转成字符串来处理 package com.rust.cal; public class Palindrome { public static boolean i ...

  2. valid palindrome(回文)

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

  3. 有趣的数-回文数(Palindrome number)

    文章转自http://blog.163.com/hljmdjlln@126/blog/static/5473620620120412525181/ 做LC上的题"Palindrome num ...

  4. Leetcode 3——Palindrome Number(回文数)

    Problem: Determine whether an integer is a palindrome. Do this without extra space. 简单的回文数,大一肯定有要求写过 ...

  5. leetcode 9 Palindrome Number 回文数

    Determine whether an integer is a palindrome. Do this without extra space. click to show spoilers. S ...

  6. palindrome number(回文数)

    Determine whether an integer is a palindrome. Do this without extra space. Some hints: Could negativ ...

  7. [LeetCode] Prime Palindrome 质数回文数

    Find the smallest prime palindrome greater than or equal to N. Recall that a number is prime if it's ...

  8. [Swift]LeetCode9. 回文数 | Palindrome Number

    Determine whether an integer is a palindrome. An integer is a palindrome when it reads the same back ...

  9. [Swift]LeetCode479. 最大回文数乘积 | Largest Palindrome Product

    Find the largest palindrome made from the product of two n-digit numbers. Since the result could be ...

随机推荐

  1. android doc 本地文档加载慢的解决办法

    从来都是FQ上谷歌官网查文档,但是有时没办法FQ,就得用sdk本地的doc文档了,由于文档内部的一些javascript,font等也需要访问Google来加载,导致了打开本地网页也巨慢无比,甚至转了 ...

  2. IIS6批量转移网站

    IIS6.0有个导出配置的功能,但你却找不到界面上的直接导入配置功能,需要用到操作系统自带的iiscnfg.vbs脚本. 1.导出当前的IIS网站配置 打开Internet信息服务(IIS)---&g ...

  3. XML中的Xpath解析的例子

    /*XPath 术语节点(Node)在 XPath 中,有七种类型的节点:元素.属性.文本.命名空间.处理指令.注释以及文档(根)节点.XML 文档是被作为节点树来对待的.树的根被称为文档节点或者根节 ...

  4. C#中Predicate<T>与Func<T, bool>泛型委托的用法实例

    本文以实例形式分析了C#中Predicate<T>与Func<T, bool>泛型委托的用法,分享给大家供大家参考之用.具体如下: 先来看看下面的例子: 1 2 3 4 5 6 ...

  5. 用css3做标签

    <!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8&quo ...

  6. WinSCP列出’/’目录项出错

    无法获得目录列表 如图所示,使用百度云虚拟机时,FTP连接服务器,出现错提示,官方给出的说法是使用其他的FTP进行连接,但是之前成功连接过,查找资料后说是打开过png,mp3等媒体文件,切换路径时出错 ...

  7. 一段画对角线的canvas代码,之前没有写过canvas代码,现在记录下来

    <canvas id="other" style="width:320px;height:320px;"></canvas> var o ...

  8. GridView - javascript 触发后台 OnSelectedIndexChanged

    1.ASPX <asp:GridView ID="gdvDealers" runat="server" AutoGenerateColumns=" ...

  9. htmlcleaner

    String xpath = "//div"; Object[] myNodes = node.evaluateXPath(xpath); for (Object obj : my ...

  10. cxgrid GridMode 等于 True 时的一些问题。

    When using grid mode, the data controller loads a fixed number of dataset records into memory. The n ...