private void findWordsUtil(char[][] board, Trie t , int i, int j, StringBuffer buff, Set<Integer> visited, Set<String> result, int col ) {
        if (i < 0 || j < 0 || i >= board.length || j >= board[i].length) {
            return;
        }

        int val = i*col + j;

        if (visited.contains(val)) {
            return;
        }

        buff.append(board[i][j]);
        String str = buff.toString();
        if(!t.startsWith(str)) {
            buff.deleteCharAt(buff.length() - 1);
            return;
        }
        visited.add(val);

        if(t.search(str)) {
            result.add(buff.toString());
        }

        findWordsUtil(board, t, i + 1, j, buff, visited, result, col);
        findWordsUtil(board, t, i, j + 1, buff, visited, result, col);
        findWordsUtil(board, t, i, j - 1, buff, visited, result, col);
        findWordsUtil(board, t, i - 1, j, buff, visited, result, col);

        buff.deleteCharAt(buff.length() - 1);
        visited.remove(val);
    }
Date 03/04/2016
@author Tushar Roy

Search for dictionary words in the board.
Idea is to use trie for the dictionary which keeps search
very efficient.

https://leetcode.com/problems/word-search-ii/
src/com/interview/graph/Boggle.java