Search⌘ K
AI Features

Solution: Append Characters to String to Make Subsequence

Understand how to determine the fewest characters to append to a source string so the target becomes a subsequence. Explore the two pointer method to efficiently match characters, minimizing additions. This lesson provides a clear approach to solving this common coding interview problem using a greedy algorithm.

Statement

You’re given two strings, source and target, made up of lowercase English letters. Your task is to determine the minimum number of characters that must be appended to the end of the source so that the target becomes a subsequence of the resulting string.

Note: A subsequence is formed by deleting zero or more characters from a string without changing the order of the remaining characters.

Constraints: ...