package leetcode;

import java.util.List;

/**
 * https://leetcode.com/problems/palindrome-pairs/
 */
public class Problem336 {
    public List<List<Integer>> palindromePairs(String[] words) {
        // TODO
        return null;
    }

    public static void main(String[] args) {
        Problem336 prob = new Problem336();
        System.out.println(prob.palindromePairs(new String[]{"abcd", "dcba", "lls", "s", "sssll"})); // [[0,1],[1,0],[3,2],[2,4]]
        System.out.println(prob.palindromePairs(new String[]{"bat", "tab", "cat"})); // [[0,1],[1,0]]
    }
}

@@ -12,16 +12,69 @@
 tcode;%0A%0A
+import java.util.ArrayList;%0Aimport java.util.Arrays;%0A
 import j
@@ -88,16 +88,16 @@
 l.List;%0A
-
 %0A/**%0A * 
@@ -251,35 +251,706 @@
     
-// TODO%0A        return null
+List%3CList%3CInteger%3E%3E answer = new ArrayList%3C%3E();%0A        for (int i = 0; i %3C words.length; i++) %7B%0A            for (int j = i + 1; j %3C words.length; j++) %7B%0A                if (isPalindrome(words%5Bi%5D + words%5Bj%5D)) %7B%0A                    answer.add(Arrays.asList(i, j));%0A                %7D%0A                if (isPalindrome(words%5Bj%5D + words%5Bi%5D)) %7B%0A                    answer.add(Arrays.asList(j, i));%0A                %7D%0A            %7D%0A        %7D%0A        return answer;%0A    %7D%0A%0A    private static boolean isPalindrome(String s) %7B%0A        for (int i = 0, j = s.length() - 1; i %3C j; i++, j--) %7B%0A            if (s.charAt(i) != s.charAt(j)) %7B%0A                return false;%0A            %7D%0A        %7D%0A        return true
 ;%0A  

Update problem 336