leetcode9
public class Solution {
public bool IsPalindrome(int x) {
if (x < )
{
return false;
}
var str = x.ToString();
var list = new List<string>();
foreach (var c in str)
{
list.Add(c.ToString());
}
var count = list.Count;
for (int i = ; i < list.Count; i++)
{
var n1 = list[i];
var n2 = list[list.Count - - i];
if (n1 != n2)
{
return false;
}
if (i >= list.Count - - i)
{
break;
}
}
return true;
}
}
https://leetcode.com/problems/palindrome-number/#/description
leetcode9的更多相关文章
- leetcode-9.回文数(水仙花数)
leetcode-9.回文数(水仙花数) 题意:给定整数,判断是否是水仙花数(回文数),返回判断结果 算法: 1.判断负数, 如果是负数直接返回false 2.将整数逐位拆解,用数组存储 3.遍历数组 ...
- 【LeetCode9】Palindrome Number★
题目描述: 解题思路: 求回文数,并且要求不能使用额外的空间.思路很简单,算出x的倒置数reverse,比较reverse是否和x相等就行了. Java代码: public class LeetCod ...
- LeetCode9 Palindrome Number
题意: Determine whether an integer is a palindrome. Do this without extra space. (Easy) 分析: 自己考虑的方法是利 ...
- [Swift]LeetCode9. 回文数 | Palindrome Number
Determine whether an integer is a palindrome. An integer is a palindrome when it reads the same back ...
- LeetCode9 回文数
题目链接:https://leetcode-cn.com/problems/palindrome-number/ 判断一个整数是否是回文数.回文数是指正序(从左向右)和倒序(从右向左)读都是一样的整数 ...
- leetcode9 Palindrome Number(按进阶要求)
题目描述 Determine whether an integer is a palindrome. An integer is a palindrome when it reads the same ...
- leetcode第九题--Palindrome Number
Problem: Determine whether an integer is a palindrome. Do this without extra space. click to show sp ...
- 图解leetcode5-10 | 和233酱一起刷leetcode系列(2)
本周我们继续来看5道磨人的小妖精,图解leetcode6-10- 多说一句,leetcode10 杀死了233酱不少脑细胞... 另: 沉迷算法,无法自拔.快来加入我们吧! 别忘了233酱的一条龙服务 ...
随机推荐
- 用pycharm提交代码,冲突之后文件丢失找回方法
1: 更新代码时, 监测到本地代码改变,需要和合并,重启之后才可以, 选择No同时,代码会被冲掉,新增加的文件也会被冲掉, 但是pycharm有一个文件历史记忆,找到之后可以找到丢失的文件. 1: 选 ...
- opencv错误(Unhandled expection at at 0x0007EEE...)
错误截图如下: 情况1:加载人脸检测分类器的时候出错,不能写相对路径一定要写绝对路径 例如:cascade.load("D:\\recognise-your-own-face2\\recog ...
- CSS border 属性和 border-collapse 属性
border 简写属性在一个声明设置所有的边框属性. 可以按顺序设置如下属性: border-width border-style border-color 如果不设置其中的某个值,也不会出问题,比如 ...
- hdu3031
题解: 左偏树模板题目 每一次合并,删除最大,修改最大 都是基本操作 代码: #include<cstdio> #include<cmath> #include<algo ...
- 客户端链接Blog
Word 2013链接Blog 1.设置共享->发布至博客->发布至博客 2.新建博客账户 3.添加新建账户信息 注意:URL内为Blog名,而非用户名 a) 在"Type of ...
- MySQL 5.7忘记密码
关闭正在运行的 MySQL : 1 [root@www.woai.it ~]# service mysql stop 运行 1 [root@www.woai.it ~]# mysqld_safe -- ...
- C#读写三菱Fx PLC 使用Fx 串口协议 读写Fx3U设备
本文将使用一个Github开源的组件库技术来读写三菱 FX PLC,使用的是基于串口的实现,不需要额外的组件,读取操作只要放到后台线程就不会卡死线程,本组件支持超级方便的高性能读写操作 github地 ...
- cool 软件 —— Carnac(实时桌面显示按键)
1. Carnac 下载地址:Carnac, the Magnificent Keyboard Utility 使用说明:carnac – 在屏幕实时显示按键操作
- WF从入门到精通学习目录
WF从入门到精通(第一章):WF简介 WF从入门到精通(第二章):workflow运行时 WF从入门到精通(第三章):workflow实例 WF从入门到精通(第四章):活动及workflow类型介绍 ...
- mschart 使用心得和部署。
参考: http://www.cnblogs.com/suguoqiang/archive/2013/01/16/2862945.html 1.在统计时可能需要多条数据,需要整合数据源 Chart1. ...