1048. Longest String Chain


DP with HashMap
1. from shortest words, words[] sort by length
2. dp with hashmap
3. for each word
why count = Math.max(count, map.get(findStr)+1); needs do max?
time: O(nlogn + n*w), n is words[i].length (1~16) , w is word length(1~1000)
space: O(n)
Last updated
Was this helpful?