@@ -0,0 +1,1913 @@
+package org.speedfirst.leetcode.array;%0A%0A/**%0A * @author jiankuan%0A * @date 12/13/14%0A */%0Apublic class WordSearch %7B%0A%0A    public boolean searchWord(char%5B%5D%5B%5D board, boolean%5B%5D%5B%5D visited, int w, int h, int curX, int curY, int curWordIdx, String word) %7B%0A        char c = word.charAt(curWordIdx);%0A        if (board%5BcurX%5D%5BcurY%5D != c) %7B%0A            return false;%0A        %7D%0A%0A        if (curWordIdx == word.length() - 1) %7B%0A            return true;%0A        %7D%0A%0A        visited%5BcurX%5D%5BcurY%5D = true;%0A        if (curX %3E 0 && !visited%5BcurX - 1%5D%5BcurY%5D && searchWord(board, visited, w, h, curX - 1, curY, curWordIdx + 1, word)) return true;%0A        if (curX %3C h - 1 && !visited%5BcurX + 1%5D%5BcurY%5D && searchWord(board, visited, w, h, curX + 1, curY, curWordIdx + 1, word)) return true;%0A        if (curY %3E 0 && !visited%5BcurX%5D%5BcurY - 1%5D && searchWord(board, visited, w, h, curX, curY - 1, curWordIdx + 1, word)) return true;%0A        if (curY %3C w - 1 && !visited%5BcurX%5D%5BcurY + 1%5D &&  searchWord(board, visited, w, h, curX, curY + 1, curWordIdx + 1, word)) return true;%0A        visited%5BcurX%5D%5BcurY%5D = false;%0A        return false;%0A    %7D%0A%0A    public boolean exist(char%5B%5D%5B%5D board, String word) %7B%0A        int h = board.length;%0A        int w = board%5B0%5D.length;%0A%0A        boolean%5B%5D%5B%5D visited = new boolean%5Bh%5D%5Bw%5D;%0A        for (int i = 0; i %3C h; i++) %7B%0A            for (int j = 0; j %3C w; j++) %7B%0A                visited%5Bi%5D%5Bj%5D = false;%0A            %7D%0A        %7D%0A%0A        for (int i = 0; i %3C h; i++) %7B%0A            for (int j = 0; j %3C w; j++) %7B%0A                if (searchWord(board, visited, w, h, i, j, 0, word)) %7B%0A                    return true;%0A                %7D%0A            %7D%0A        %7D%0A%0A        return false;%0A    %7D%0A%0A    public static void main(String%5B%5D args) %7B%0A        char%5B%5D%5B%5D board = new char%5B1%5D%5B1%5D;%0A        board%5B0%5D%5B0%5D = 'a';%0A        WordSearch ws = new WordSearch();%0A        boolean res = ws.exist(board, %22a%22);%0A        System.out.println(res);%0A    %7D%0A%7D%0A

add WordSearch