Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- // Runtime: 142 ms
- #include <iostream>
- #include <string>
- using namespace std;
- class Solution {
- public:
- bool isPalindrome(int x) {
- string number = to_string(x);
- int size = number.size();
- bool checker = true;
- for (int j = 0; (j < size / 2) && checker; j++) {
- if (number[j] != number[(size - 1) - j])
- checker = false;
- }
- return checker;
- }
- };
- int main(void)
- {
- Solution s;
- int num = 112; // change the number from here..!
- if (s.isPalindrome(num))
- {
- cout << "\nPalindrome..!\n\n";
- }
- else
- {
- cout << "\nNot Palindrome..!\n\n";
- }
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement