If we imagine a worst case as the grid consisting of the letters that each start a word of length that spans the entire grid, which is n * n, then (as given by the solution) we loop over each element of the grid, which is n * n times. So for each character in the grid that we start from, we have to explore n * n - 1 other characters.
For example grid:
a, b, c
d, e, f
g, h i
and dictionary:
"abcdefghi", "bacdefghi", cbadeghgi", .... "ihgfedcba"
Type your question above this line.
Course: https://www.educative.io/collection/5642554087309312/5679846214598656
Lesson: https://www.educative.io/collection/page/5642554087309312/5679846214598656/170002