Memoization III: remembering the bad paths
This problem was very interesting, I tried it without memoization and it ran into TLE (Time Limit Exceeded), adding memoization for the bad paths solved it. Let's see. Interleaving String - LeetCode 97. Interleaving String Medium 3605 193 Add to List Share Given strings s1 , s2 , and s3 , find whether s3 is formed by an interleaving of s1 and s2 . An interleaving of two strings s and t is a configuration where they are divided into non-empty substrings such that: s = s 1 + s 2 + ... + s n t = t 1 + t 2 + ... + t m |n - m| <= 1 The interleaving is s 1 + t 1 + s 2 + t 2 + s 3 + t 3 + ... or t 1 + s 1 + t 2 + s 2 + t 3 + s 3 + ... Note: a + b is the concatenation of strings a and b . Example 1: Input: s1 = "aabcc"...