Skip to content

Commit 787b63b

Browse files
author
Joseph Luce
authored
Update 1048_longest_string_chain.md
1 parent c848b34 commit 787b63b

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

leetcode/medium/1048_longest_string_chain.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
- C = Longest character word
99

1010
We can come up with a recursive solution quite easily by removing each letter and calling the next recursion function on each newly formed word.
11-
However, this would equate to a run-time of O(C^C), since we have to do this N times, and each time we have to delete each character O(NC), it would then be O(NC) \* O(C^C).
11+
However, this would equate to a run-time of O(C^C), since we have to do this N times it would then be O(N) \* O(C^C).
1212

1313
We can improve our run-time by using memoization, instead of redoing checks, we just check once for each path and save that result.
1414
So if we can only build a chain of 3 with 'abcd', if given 'abcde', when it comes to removing 'e', we don't need to check each character of 'abcd' again, instead just return 3.

0 commit comments

Comments
 (0)