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. 北大ACM(POJ1002-487-3279)

    Question:http://poj.org/problem?id=1002问题点:字符映射.选重复项及排序. Memory: 1136K Time: 813MS Language: C++ Res ...

  2. oracle是数据库的学习第一节:数据库的安装

    一.本地oracle服务器 1.安装oracle服务器,可以到oracle官方网站上下载与自己电脑匹配的服务器,一般用10g,或者11g; 2.打开cmd,打开sql*plus,之后可以写SQL语句了 ...

  3. iOS 拷贝、剪切和粘贴理论基础(转)

    简介 在iPhone OS 3.0之后,用户可以在一个应用程序上拷贝文本.图像.或其它数据,然后粘贴到当前或其它应用程序的不同位置上.比如,您可以从某个电子邮件中拷贝一个地址,然后粘贴到Contact ...

  4. JavaScript代码检查工具 — JSHint

    静态代码检查是开发工作中不可缺少的一环,毕竟对于程序化的工作人的眼睛是不可靠的,更何况是自己的眼睛看自己的代码.即使最后的运行结果通过,但可能存在一些未定义的变量.定义了但最后没用过的变量.分号有没有 ...

  5. 普通树(有根树)C++

    对于普通树实现的细节包括 1 树结点的结构体 2 初始化及删除树结点(关注内存泄露) 3 递归先序遍历 4 通过关键值的查询操作,返回关键值的结点 5 凹入表实现 6 广义表实现 7 非递归先序遍历, ...

  6. linux 硬盘相关命令学习

    summary: 查看硬盘信息:几块硬盘,品牌,容量 查看分区信息 参考资料: Linux下查看磁盘分区命令详解: http://blog.chinaunix.net/uid-26119273-id- ...

  7. 初试集群虚拟化搭建(二)—— Xen, kvm, OpenStack, VMware ESXi, Citrix XenServer等种种选择

    小伙伴们找到了一些主流方案的资料,最终选择了XenServer6.5作为平台搭建. Xen 特点: 功能强大,支持Linux的各种发行版本 通常是在现有Linux操作系统上安装,是一种半虚拟化的安装方 ...

  8. 认识HTML5

    引言,认识两个标准制定的组织 在讲什么是Html5之前得先了解两个组织:WHATWG :网页超文本技术工作小组(英语:Web Hypertext Application Technology Work ...

  9. css中单位px,em,rem的区别

    1,px像素(Pixel).相对长度单位.像素px是相对于显示器屏幕分辨率而言的. 2,em是相对长度单位.相对于当前对象内文本的字体尺寸.如当前对行内文本的字体尺寸未被人为设置,则相对于浏览器的默认 ...

  10. 纯CSS实现多选组件

    mark: http://blog.meathill.com/tech/fe/create-multiple-select-component-with-pure-css.html Demo: 小宝3 ...