diff --git a/9_palindrome_number/main.cpp b/9_palindrome_number/main.cpp new file mode 100644 index 0000000..a2e35d3 --- /dev/null +++ b/9_palindrome_number/main.cpp @@ -0,0 +1,19 @@ +#include +using namespace std; + +class Solution { +public: + bool isPalindrome(int x) { + if (x < 0) return false; + + string num = to_string(x); + int len = num.length(); + for (int i = 0; i < len / 2; i++) { + if (num[i] != num[len - i - 1]) { + return false; + } + } + + return true; + } +}; \ No newline at end of file