LeetCode 1639. Number of Ways to Form a Target String Given a Dictionary

preview_player
Показать описание

Рекомендации по теме
Комментарии
Автор

Just add one statement, i.e. if return 0 instead of if word_index==w_n: return 0, to avoid excess cases.It runs much faster..coz reamining length of target can never be greater than remaining length of some word in words ..Great solution and very well explained .Thanks!! :)

ketanraghunathraut
Автор

I used a hash table unordered_map<char, vector<int>> to pre-compute all indexes of a particular character. next i used recursion with 2d array for memoization but still i got tle in the contest.

ishaanmarjara