Robot Collect Points

please provide some hints .
my approach :
calling recursion on three cells.

Replied on other same thread by you

I hope I’ve cleared your doubt. I ask you to please rate your experience here
Your feedback is very important. It helps us improve our platform and hence provide you
the learning experience you deserve.

On the off chance, you still have some questions or not find the answers satisfactory, you may reopen
the doubt.

please provide some hints . my approach : calling recursion on three cells.

@RAHUL
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;
}
2. start from 0,0 to m,m
do a dfs travesal from each i,j cell
3. 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

1 Like

thanks rated 5 stars.