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 ...
随机推荐
- Android布局属性全面剖析
第一类:属性值为true或false android:layout_centerHrizontal 水平居中 android:layout_centerVertical 垂直居中 android:la ...
- JSP之session
index.jsp: <form id="form1" name="form1" method="post" action=" ...
- Agile.Net 组件式开发平台 - 脚本管理组件
脚本管理组件用于管理系统查询脚本,由于数据查询的复杂性和可变性,平台规范要求使用查询使用建立在脚本管理器中的SQL语句.新增.更新.删除数据采用数据访问支持库API. 示例如下: 首先在脚本管理器中定 ...
- OC4_单例
// // MusicManager.h // OC4_单例 // // Created by zhangxueming on 15/6/19. // Copyright (c) 2015年 zhan ...
- jQuery学习一:jQuery中的ready和load事件
//ready事件 $(document).ready(function(){ 代码........ }); //ready事件简写: $(function(){ 代码........ }); //l ...
- springMVC学习篇 - 搭建环境及关键点
springMVC是spring家族中一个重要的组件,和struts一样作为一套前台框架被广泛的应用于各种项目. 之前在很多项目组都用到springMVC,只感觉很强大,但是对这套框架的知识了解比较少 ...
- 基本排序算法的java实现
本例子实现了一些常见的排序算法,注释中也有一些关于这些算法的思想的描述,这里不做多说,直接上代码. import java.awt.List; import java.util.ArrayList; ...
- ZigBee组网原理
Zigbee组建一个完整的网络包含两个步骤:网络初始化和节点加入网络.其中,节点加入网络可以分为通过协调器直接连接入网和通过已有父节点入网.下面来依次说明. 1. 网络初始化 ZigBee网络初始化只 ...
- jQuery获取同级元素
next()相邻下一个同级元素 prev()相邻上一个同级元素 siblings()所有同级元素 $("#id").next(); $("#id").prev( ...
- get post
浅谈HTTP中Get与Post的区别 2009-03-31 14:51 by hyddd, 248341 阅读, 74 评论, 收藏, 编辑 Http定义了与服务器交互的不同方法,最基本的方法有4种, ...