@@ -0,0 +1,1997 @@
+import java.util.*;%0A%0Apublic class Solution %7B%0A    public List%3CString%3E findWords(char%5B%5D%5B%5D board, String%5B%5D words) %7B%0A        Set%3CString%3E list = new HashSet%3CString%3E();%0A        for(int i=0; i%3Cwords.length; i++) %7B%0A            boolean flag = true;%0A            for(int x = 0; x %3C board.length && flag; x++)%7B%0A                for(int y = 0; y%3Cboard%5B0%5D.length && flag; y++)%7B%0A                    boolean %5B%5D%5B%5D visited = new boolean%5Bboard.length%5D%5Bboard%5B0%5D.length%5D;%0A                    visited%5Bx%5D%5By%5D = true;%0A                    if(finding(x, y, visited, 0, board, words%5Bi%5D)) %7B%0A                        flag = false;%0A                    %7D%0A                %7D%0A            %7D%0A            if(!flag) list.add(words%5Bi%5D);%0A        %7D%0A        return new ArrayList%3CString%3E(list);%0A    %7D%0A    %0A    private final int%5B%5D dx = %7B0, 1, 0 , -1%7D;%0A    private final int%5B%5D dy = %7B1, 0, -1 , 0%7D;%0A    %0A    private boolean finding(int x, int y, boolean%5B%5D%5B%5D visited, int k, char%5B%5D%5B%5D board, String word) %7B%0A        if(k == word.length()) return true;%0A        if(word.charAt(k) == board%5Bx%5D%5By%5D) %7B%0A            for(int i=0; i%3Cdx.length; i++) %7B%0A                int xx = x + dx%5Bi%5D;%0A                int yy = y + dy%5Bi%5D;%0A                if(inBoundary(xx, yy, board.length, board%5B0%5D.length) && !visited%5Bxx%5D%5Byy%5D) %7B%0A                    visited%5Bxx%5D%5Byy%5D = true;%0A                    if(finding(xx, yy, visited, k+1, board, word)) return true;%0A                    visited%5Bxx%5D%5Byy%5D = false;%0A                %7D%0A            %7D%0A        %7D%0A        return false;%0A    %7D%0A    %0A    private boolean inBoundary(int x, int y, int width, int height) %7B%0A        return x%3E=0 && x%3Cwidth && y%3E=0 && y%3Cheight;%0A        %0A    %7D%0A    %0A    public static void main(String%5B%5D args) %7B%0A        Solution a = new Solution();%0A        char%5B%5D%5B%5D board = %7B%0A            %7B'o','a','a','n'%7D,%0A            %7B'e','t','a','e'%7D,%0A            %7B'i','h','k','r'%7D,%0A            %7B'i','f','l','v'%7D%0A        %7D;%0A        String%5B%5D dict = %7B%22oath%22,%22pea%22,%22eat%22,%22rain%22%7D;%0A        System.out.println(a.findWords(board, dict));%0A    %7D%0A%7D%0A

Create Word_Search_II.java