Two line C++ solution(Enumeration method)


  • 0
    O
    class Solution {
    public:
        int largestPalindrome(int n) {
            vector<long> res = {9, 9009, 906609, 99000099, 9966006699, 999000000999, \
                        99956644665999, 9999000000009999};
            return int(res[n - 1] % 1337);    
        }
    };
    

Log in to reply
 

Looks like your connection to LeetCode Discuss was lost, please wait while we try to reconnect.