2-Line 1ms Java Solution


  • 1

    With a limitation of 1-8 for the range of n, a simple lookup table is best. This is a terrible question.

    public class Solution {
    private static int[] LP = new int[] { 0, 9, 987, 123, 597, 677, 1218, 877, 475 };

    public int largestPalindrome(int n) {
        return LP[n];
    }
    

    }


Log in to reply
 

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