Robot Collect Point-Recursion

I am unable to come up with an approach to solve this problem. Please help me with this.

@vkth
Intuitively, start from every cell and try to build a word in the dictionary. Backtracking (dfs) is the powerful way to exhaust every possible ways. Apparently, we need to do pruning when current character is not in any word.

steps:
1.make trie for the input string array

class TrieNode {
TrieNode[] next = new TrieNode[26];
String word;
}

  1. start from 0,0 to m,m
    do a dfs travesal from each i,j cell
  2. in dfs function update the current character to # so that the current character cannot be used again
    a. check for all 4 positiion i-1, j || i+1, j || i,j+1 || j,j-1
    b. remember to backtrack the position

i hope this explains how u would go about the problem

Hi Abha,
This is the problem.

@vkth
you can refer to this code

Thank you. :slight_smile: