Hahahahahahaha, I’m so happy, today’s code time and memory consumption are half of the official code haha
(Because the official code is written in C#, I use C++, manual dog head)
Title
To determine whether an integer is a palindrome. The palindrome number refers to the same integer in both positive order (from left to right) and reverse order (from right to left).
Example 1:
Input: 121
Output: true
Example 2:Input: -121
Output: false< br>Explanation: Reading from left to right, it is -121. Reading from right to left, it is 121-. Therefore it is not a palindrome.
Example 3:Input: 10
Output: false
Explanation: Reading from right to left, it is 01. Therefore it is not a palindrome.
Code
1 class Solution {
2 public:
3 bool isPalindrome(int x) {
4 int a = 0;
5 if (x == 0)
6 return true;
7 else if (x <0 || x% 10 == 0)
8 return false;
9 while(x > a){
10 a = a * 10 + x% < span style="color: #800080;">10;
11 x/=10;
12 }
13 return x == a || x = = a / 10;
14 }
15 };
View Code < /div>
1 class Solution {
2 public:
3 bool isPalindrome(int x) {
4 int a = 0;
5 if (x == 0)
6 return true;
7 else if (x <0 || x% 10 == 0)
8 return false;
9 while(x > a){
10 a = a * 10 + x% < span style="color: #800080;">10;
11 x/=10;
12 }
13 return x == a || x = = a / 10;
14 }
15 };
View Code< /p>
1 class Solution {
2 public:
3 bool isPalindrome(int x) {
4 int a = 0;
5 if (x == 0)
6 return true;
7 else if (x <0 || x% 10 == 0)
8 return false;
9 while(x > a){
10 a = a * 10 + x% < span style="color: #800080;">10;
11 x/=10;
12 }
13 return x == a || x = = a / 10;
14 }
15 };
WordPress database error: [Table 'yf99682.wp_s6mz6tyggq_comments' doesn't exist]SELECT SQL_CALC_FOUND_ROWS wp_s6mz6tyggq_comments.comment_ID FROM wp_s6mz6tyggq_comments WHERE ( comment_approved = '1' ) AND comment_post_ID = 3085 ORDER BY wp_s6mz6tyggq_comments.comment_date_gmt ASC, wp_s6mz6tyggq_comments.comment_ID ASC