educative.io

Time complexity of Word Search II

The provided time complexity for the solution is O(n * 3^l), where n is the number of grid squares and l is the max length among search terms. It seems like the logic is: from each of n grid squares, we perform a dfs. Could we perform more than one dfs from a given square? Could we perform up to s, where s is the number of search terms? If so, is our time complexity O(n * 3^l * s)?


Course: Grokking Coding Interview Patterns in Python - AI-Powered Learning for Developers
Lesson: https://www.educative.io/courses/grokking-coding-interview-patterns-python/solution-word-search-ii