educative.io

Space complexity of Word Search II

The provided space complexity for the solution is O(m + n), where m is the total number of chars among search terms, and n is the length of the grid, with our space-consuming assets being the trie and the recursive stack to search the grid. Can this be simplified to O(m)? The trie is of size O(m), and the recursive stack never exceeds O(m) in length.


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