[LeetCode] 9. Palindrome Number

0

LeetCode

목록 보기
5/58
post-thumbnail
post-custom-banner

[LeetCode] 9. Palindrome Number

풀이

#include <string>

class Solution {
public:
    bool isPalindrome(int x) {
        string xStr = to_string(x);
        int l = 0;
        int r = xStr.length()-1;
        while(l<r){
            if(xStr[l] != xStr[r]) return false;
            l++;
            r--;
        }
        return true;
    }
};
profile
Be able to be vulnerable, in search of truth

0개의 댓글