package leetcode;

/**
 * https://leetcode.com/problems/largest-palindrome-product/
 */
public class Problem479 {
    public int largestPalindrome(int n) {
        // TODO
        return 0;
    }

    public static void main(String[] args) {
        Problem479 prob = new Problem479();
        System.out.println(prob.largestPalindrome(2)); // 987
    }
}

@@ -161,191 +161,1621 @@
     
-// TODO%0A        return 0;%0A    %7D%0A%0A    public static void main(String%5B%5D args) %7B%0A        Problem479 prob = new Problem479();%0A        System.out.println(prob.largestPalindrome(2)); // 987
+StringBuilder largestStr = new StringBuilder();%0A        for (int i = 0; i %3C n; i++) %7B%0A            largestStr.append(9);%0A        %7D%0A        StringBuilder smallestStr = new StringBuilder();%0A        smallestStr.append(1);%0A        for (int i = 1; i %3C n; i++) %7B%0A            smallestStr.append(0);%0A        %7D%0A        long largest = Long.parseLong(largestStr.toString());%0A        long smallest = Long.parseLong(smallestStr.toString());%0A        long max = 0;%0A        for (long i = largest; i %3E= smallest; i--) %7B%0A            for (long j = largest; j %3E= smallest; j--) %7B%0A                long num = i * j;%0A                if (isPalindrome(Long.toString(num))) %7B%0A                    max = Math.max(max, num);%0A                %7D%0A            %7D%0A        %7D%0A        return (int) (max %25 1337);%0A    %7D%0A%0A    private static boolean isPalindrome(String str) %7B%0A        for (int i = 0, j = str.length() - 1; i %3C j; i++, j--) %7B%0A            if (str.charAt(i) != str.charAt(j)) %7B%0A                return false;%0A            %7D%0A        %7D%0A        return true;%0A    %7D%0A%0A    public static void main(String%5B%5D args) %7B%0A        Problem479 prob = new Problem479();%0A        System.out.println(prob.largestPalindrome(1)); // 9%0A        System.out.println(prob.largestPalindrome(2)); // 987%0A        System.out.println(prob.largestPalindrome(3)); // 123%0A        System.out.println(prob.largestPalindrome(4)); // 597%0A        System.out.println(prob.largestPalindrome(5)); // 677%0A        System.out.println(prob.largestPalindrome(6)); // 1218%0A        System.out.println(prob.largestPalindrome(7)); // 877%0A        System.out.println(prob.largestPalindrome(8)); // 475
 %0A   

Update problem 479