Skip to content

Commit

Permalink
Create Palindrome Number.cpp
Browse files Browse the repository at this point in the history
  • Loading branch information
witheunjin authored Jun 27, 2020
1 parent 3091668 commit 6fbbb4d
Showing 1 changed file with 15 additions and 0 deletions.
15 changes: 15 additions & 0 deletions LeetCode/Palindrome Number.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
class Solution {
public:
bool isPalindrome(int x) {
if(x<0) return false;
if(x<10) return true;
int i=0;
string s = to_string(x);
int length = s.length();
for(i=0; i<length; ++i) {
if(s[i] != s[length-i-1]) break;
}
if(i == length) return true;
return false;
}
};

0 comments on commit 6fbbb4d

Please sign in to comment.