leetcode4 Valid Palindrome回文数
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回文数的更多相关文章
- Palindrome 回文数
回文数,从前到后,从后到前都一样 把数字转成字符串来处理 package com.rust.cal; public class Palindrome { public static boolean i ...
- valid palindrome(回文)
Given a string, determine if it is a palindrome, considering only alphanumeric characters and ignori ...
- 有趣的数-回文数(Palindrome number)
文章转自http://blog.163.com/hljmdjlln@126/blog/static/5473620620120412525181/ 做LC上的题"Palindrome num ...
- Leetcode 3——Palindrome Number(回文数)
Problem: Determine whether an integer is a palindrome. Do this without extra space. 简单的回文数,大一肯定有要求写过 ...
- leetcode 9 Palindrome Number 回文数
Determine whether an integer is a palindrome. Do this without extra space. click to show spoilers. S ...
- palindrome number(回文数)
Determine whether an integer is a palindrome. Do this without extra space. Some hints: Could negativ ...
- [LeetCode] Prime Palindrome 质数回文数
Find the smallest prime palindrome greater than or equal to N. Recall that a number is prime if it's ...
- [Swift]LeetCode9. 回文数 | Palindrome Number
Determine whether an integer is a palindrome. An integer is a palindrome when it reads the same back ...
- [Swift]LeetCode479. 最大回文数乘积 | Largest Palindrome Product
Find the largest palindrome made from the product of two n-digit numbers. Since the result could be ...
随机推荐
- boost.ASIO-可能是下一代C++标准的网络库
曾几何时,Boost中有一个Socket库,但后来没有了下文,C++社区一直在翘首盼望一个标准网络库的出现,网络上开源的网络库也有不少,例如Apache Portable Runtime就是比较著名的 ...
- 重叠I/O之可等待的重叠I/O【系列一】
一 什么是异步I/O 同步I/O和异步I/O的关键不同就是在发出I/O请求后,线程是否会阻塞.当线程发出一个设备I/O请求的时候,线程会被挂起来,直到设备完成I/O请求为止,这称之为同步I/O.而对于 ...
- The influence of informal governance mechanisms on knowledge integration
Title:The influence of informal governance mechanisms on knowledge integration within cross-function ...
- C#中Predicate<T>与Func<T, bool>泛型委托的用法实例
本文以实例形式分析了C#中Predicate<T>与Func<T, bool>泛型委托的用法,分享给大家供大家参考之用.具体如下: 先来看看下面的例子: 1 2 3 4 5 6 ...
- host文件的作用和介绍
在Window系统中有个Hosts文件(没有后缀名)在Windows98系统下该文件在Windows目录,在Windows2000/XP系统中位于C:\Winnt\System32\Drivers\E ...
- Qt学习总结-ui篇(二)
qccs定义圆角 border-radius:10px; 如果想给特定位置定义圆角,如: 左上角:border-left-top-radius:10px; 右下角色:border-right-bo ...
- Contiki系统介绍
本文内容来源为contiki英文介绍,自己为了学习,将其大致翻译成中文,以便了解. 欢迎转载,转载请注明来源,如果有什么翻译不合适的地方,请留言指出,相互交流学习. 介绍 Contiki是一个开放源码 ...
- java.util.HashSet源码分析
public class HashSet<E> extends AbstractSet<E> implements Set<E>, Cloneable, java. ...
- 服务器 tfs不提供 TeamFoundation服务。基础连接已经关闭
服务器 tfs(服务器名或url)不提供 TeamFoundation服务.基础连接已经关闭,发送时发生错误.TFS突然间连接不上到,到服务器上配置团队项目的组成员资格提示这样的错误,客户端连接的时候 ...
- 删除vim-minimal导致sudo不可用
Ok, if anyone ends up in a similar situation, you can use pkexec yum install sudo. pkexec will let y ...