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 ...
随机推荐
- antuomake 生成configure的使用
configure 作为编译配置脚本,有大量选项可供不同编译需求,这些选项直 接作用到最终生成的Makefile文件 问题:automake默认的gcc编译选项为-Wall -O2 -g,怎么改为我们 ...
- linux make clean
make clean仅仅是清除之前编译的可执行文件及配置文件. 而make distclean要清除所有生成的文件. Makefile 在符合GNU Makefiel惯例的Makefile中,包含了一 ...
- maven增量编译
最近由于不清楚maven(2.2.x)增量编译的机制,导致应用出现了一个当时觉得非常诡异的一个问题.先描述一下问题. 背景是应用A有一个公用的base包,版本为1.6.6-SNAPSHOT,应 ...
- HTML 中的字符集、ASCII、 ISO-8859-1、符号之间的关系和 HTML URL 编码注意的事项
一.HTML 实体 1.什么是HTML 实体? 在 HTMl 中,某些字符是保留的.小于号 (<) 和 大于号 (>), 浏览器会误认为是标签 如果希望正确地显示预留字符,必须在 HTML ...
- php验证码的简单例子
php随机验证码: <?php $image_width=140; $image_height=50; srand(microtime()*10000); ...
- Demo学习: Collapsible Panels
Collapsible Panels 设置TUniPanel布局属性,布局属性在Ext里是比较常用的属性,当前版本虽已经提供了布局功能,但很不完善,比如当Panel.TitlePosition=tpR ...
- Kakfa揭秘 Day2 Kafka内核再揭秘
Spark Streaming揭秘 Day33 Kafka内核再揭秘 优秀的框架会把引擎做到极致,Kafka就是这样,让我们再深入一下研究. 设计目标 kafka系统有着比较独特的的设计,包括5点: ...
- zhuan:ubuntu下安装Apache2+php+Mysql
from: http://www.cnblogs.com/lynch_world/archive/2012/01/06/2314717.html ubuntu下安装Apache+PHP+Mysql 转 ...
- The Best Rank (25)(排名算法)
To evaluate the performance of our first year CS majored students, we consider their grades of three ...
- Nginx upstream的5种权重分配方式
.轮询(默认) 每个请求按时间顺序逐一分配到不同的后端服务器,后端服务器down掉,能自动剔除 .weight 指定轮询几率,weight和访问比率成正比,用于后端服务器性能不均的情况. upstre ...