solution.json 2.3 KB
Newer Older
每日一练社区's avatar
每日一练社区 已提交
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48
{
  "type": "code_options",
  "author": "csdn.net",
  "source": "solution.md",
  "exercise_id": "a6489253236344e493b4d6b1b00fc19d",
  "keywords": "数学",
  "title": "回文数",
  "desc": [
    {
      "content": "\n<p>给你一个整数 <code>x</code> ,如果 <code>x</code> 是一个回文整数,返回 <code>true</code> ;否则,返回 <code>false</code> 。</p><p>回文数是指正序(从左向右)和倒序(从右向左)读都是一样的整数。例如,<code>121</code> 是回文,而 <code>123</code> 不是。</p><p> </p><p><strong>示例 1:</strong></p><pre><strong>输入:</strong>x = 121<strong><br />输出:</strong>true</pre><p><strong>示例 2:</strong></p><pre><strong>输入:</strong>x = -121<strong><br />输出:</strong>false<strong><br />解释:</strong>从左向右读, 为 -121 。 从右向左读, 为 121- 。因此它不是一个回文数。</pre><p><strong>示例 3:</strong></p><pre><strong>输入:</strong>x = 10<strong><br />输出:</strong>false<strong><br />解释:</strong>从右向左读, 为 01 。因此它不是一个回文数。</pre><p><strong>示例 4:</strong></p><pre><strong>输入:</strong>x = -101<strong><br />输出:</strong>false</pre><p> </p><p><strong>提示:</strong></p><ul>\t<li><code>-2<sup>31</sup> <= x <= 2<sup>31</sup> - 1</code></li></ul><p> </p><p><strong>进阶:</strong>你能不将整数转为字符串来解决这个问题吗?</p>",
      "language": "markdown"
    }
  ],
  "answer": [
    {
      "content": "",
      "language": "python"
    }
  ],
  "prepared": [
    [
      {
        "content": "",
        "language": "python"
      }
    ],
    [
      {
        "content": "",
        "language": "python"
      }
    ],
    [
      {
        "content": "",
        "language": "python"
      }
    ]
  ],
  "template": {
    "content": "import math\nclass Solution:\n\tdef isPalindrome(self, x: int) -> bool:\n\t\to = x\n\t\ty = 0\n\t\twhile x > 0:\n\t\t\tr = x % 10\n\t\t\ty = y*10+r\n\t\t\tx = int(math.floor(x/10))\n\t\treturn y == o\n# %%\ns = Solution()\nprint(s.isPalindrome(x = 121))",
    "language": "python"
  },
  "node_id": "dailycode-87c05af61eca47f899c58a92805fb9db",
  "license": "csdn.net",
  "created_at": 1637894161,
  "topic_link": "https://bbs.csdn.net/topics/600471100"
}