Intuition

Find whether the characters in t exist in order in s, and tack on the remaining letters in the end, which amounts to whatever characters are left in the insertion.

Complexity

Runtime

Space

Code

class Solution:
    def appendCharacters(self, s: str, t: str) -> int:
        j = 0
 
        for i in range(len(s)):
            if j >= len(t):
                break
            elif s[i] == t[j]:
                j += 1
 
        return len(t) - j

Notes

Cards

START Basic Front: Append Characters To String To Make Subsequence Back: Check if the letters of t occur in order within s END


References