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. jQuery之手风琴图片

    <!DOCTYPE HTML> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <m ...

  2. MDAC 在WINDOWS XP SP3 不能安装 的解决方法

    MDAC 在WINDOWS XP SP3 不能安装 的解决方法 解决步骤如下: c:/windows/inf 下找出mdac.inf 然后点右键->安装.在弹出提示路径选取c:/windows/ ...

  3. linux中FTP自动备份VPS脚本

    服务器多了,网站也越来越多,总觉得不整个备份心里放不下心,并且有好几次rm的操作失误,造成难以挽回的损失.并且大多数的VPS提供商是不提供自动备份功能或者此功能收费价格略高.所以自己还是有必要把这个工 ...

  4. 浏览器userAgent大全

    iPhone ●iOSMozilla/5.0 (iPhone; U; CPU like Mac OS X; en) AppleWebKit/420+ (KHTML, like Gecko) Versi ...

  5. OC1_点语法

    // // Dog.h // OC1_点语法 // // Created by zhangxueming on 15/6/16. // Copyright (c) 2015年 zhangxueming ...

  6. (转)Mongodb相对于关系型数据库的优缺点

    与关系型数据库相比,MongoDB的优点:①弱一致性(最终一致),更能保证用户的访问速度:举例来说,在传统的关系型数据库中,一个COUNT类型的操作会锁定数据集,这样可以保证得到“当前”情况下的精确值 ...

  7. java新手笔记29 读取文件

    1.读取文件 package com.yfs.javase; import java.io.FileInputStream; import java.io.FileReader; import jav ...

  8. Java使用wkhtmltox实现HTML代码生成PDF文档或者图片

    由于项目需要,把HTML代码转为PDF或者图片进行保存.最开始使用Flying Saucer来把HTML代码生成为PDF文档,功能已经开发出来了,也能够完成转换功能,期间也遇到了中文支持以及图片路径的 ...

  9. 文件存储之-内存文件系统tmpfs

    前言 我们都知道,对于单台服务器来说,除了 CPU ,内存就是我们存储数据最快的设备.如果可以把数据直接存储在内存中,对于性能的提升就不言而喻了.那么我们先来讲讲如何使用内存来存储文件. 首先,我们先 ...

  10. BroadcastReceiver

    BroadcastReceiver 广播接受者 Android中, Broadcast是一种数据传递的方式/通信方式. Brodadcast 是Android 系统组件之一 广播的特性 1. 由一个发 ...