<2024年4月>
31123456
78910111213
14151617181920
21222324252627
2829301234
567891011

统计

  • 随笔 - 57
  • 文章 - 7
  • 评论 - 0
  • 引用 - 0

常用链接

留言簿

随笔分类

随笔档案

文章分类

文章档案

Blog

Coder 必备技巧

Compiler for Wurq

搜索

  •  

最新评论

阅读排行榜

评论排行榜

【LeeCode 2017/06/22】9. Palindrome Number
 1 class Solution {
 2 public:
 3     bool isPalindrome(int x) {
 4         
 5         if (x < 0)return false;
 6 
 7         list<int> l;
 8         while (x){
 9             l.push_back(x % 10);
10             x /= 10;
11         }
12 
13         while (!l.empty()) {
14             if (l.front() == l.back()) {
15                 l.pop_front();
16                 if(!l.empty())
17                     l.pop_back();
18             }
19             else
20                 return false;
21         }
22         return true;
23     }
24 };

posted on 2017-06-22 10:29 Wurq 阅读(66) 评论(0)  编辑 收藏 引用 所属分类: 【LeeCode 每日N题】


只有注册用户登录后才能发表评论。
网站导航: 博客园   IT新闻   BlogJava   知识库   博问   管理