【Leetcode】回文数 @ systemime | 2022-01-30T16:06:59+08:00 | 1 分钟阅读 | 更新于 2022-01-30T16:06:59+08:00

描述

题解

python-1

转换为字符串是最快捷的手段

"""
4:06 PM	info
		解答成功:
		执行耗时:52 ms,击败了87.24% 的Python3用户
		内存消耗:14.9 MB,击败了72.26% 的Python3用户
"""
class Solution:
    def isPalindrome(self, x: int) -> bool:
        if x<0:
            return False

        cc = str(x)
        if cc == cc[::-1]:
            return True
        return False

python-2

当然,还是要正规的做一下

"""然后我觉得,这就是为什么不要没事重复造轮子的理由,还不如原生的快
4:46 PM	info
		解答成功:
		执行耗时:60 ms,击败了61.73% 的Python3用户
		内存消耗:14.9 MB,击败了82.69% 的Python3用户
"""
class Solution:
    def isPalindrome(self, x: int) -> bool:
        if x < 0:
            return False

        if 0 <= x < 10:
            return True

        ss = x
        num = 0
        while x > 0:
            num = num * 10 + x % 10
            x //= 10

        return num == ss

© 2018 - 2022 systemime 的博客

Powered by Hugo with theme Dream.

---

avatar
关于我

systemime 的博客

记录一些生活与技术的事或思考

毕业于 🏫 山东科技大学泰山科技学院

目前职位为Python后端开发工程师

热爱代码,热爱开源

主要的技术栈是:

  • python
  • celery
  • django
  • shell
  • sql
  • go
  • nginx

爱好

  • 羽毛球
  • 编码
我的一些开源项目

计划或项目:

  • skill_test ➡️ 一个包含项目常用的django模板:常用脚本、单测方法、数据库连接池、异步请求池,restful风格的回调接口管理器 60%
  • Vbox ➡️ 一个基于k8s和docker的容器云平台,早期项目代码较简单 90%
  • YuQue-Assistant ➡️ 用于批量拉取语雀工作区文章,使用进程池+协程
  • 一个代理池 60%
  • simple_db_pool ➡️ 一个简单数据库连接池 100%
  • 一个电报消息转发脚本 90%
  • 使用flutter做一个app 计划中
  • 其他若干脚本(bilibili、微博图片视频下载、文件对比、图片颜色提取…)
其他

如果你喜欢我的博客、开源项目或者它们可以给你带来帮助,可以赏一杯咖啡 ☕ 给我。~

If you like my open source projects or they can help you. You can buy me a coffee ☕.~

PayPal

https://paypal.me/systemime

支付宝赞赏码

alipay

微信赞赏码

wechat

最好附加一下信息或者留言,方便我可以将捐助记录 📝 下来,十分感谢 🙏。

It is better to attach some information or leave a message so that I can record the donation 📝, thank you very much 🙏.