LeetCode 472 | Concatenated Words | HashSet | Recursion | Java

preview_player
Показать описание
Рекомендации по теме
Комментарии
Автор

For the time and space complexity,
Space is O(n) for each string in the set
Time is O(n) for function, but inside this function has a helper to call it recursively
the worst case for helper function is O(k^2) where k is the length of the word because it could keep calling every single character when it almost match but it actually didn't match!
Therefore the totally time complexity is O(n*k^2)

sleepycracker
join shbcf.ru