Description
Solutions
Determine Minimum Characters to Append

Given two strings, searchWord and resultWord:

Determine the minimum number of characters you need to append to resultWord so that it becomes a subsequence of searchWord.

Example:

Input: searchWord = "abcz" resultWord = "azdb"

Output: 2

Explanation: By appending 'd' and 'b' to "azdb", we can transform it into a subsequence of "abcz".

Understanding the Problem:

A subsequence of a string is derived by deleting some or no characters from it without changing the order of the remaining characters. For example:

"ace" is a subsequence of "abcde" because 'a', 'c', and 'e' appear in order.

"ace" is NOT a subsequence of "abcde" because 'e' appears before 'c'.

In this problem:

Input: Two strings, searchWord and resultWord.

Output: The number of characters to append to resultWord so that all characters in resultWord appear in order as a subsequence in searchWord.

Example 1:

Input:  searchWord = "abcz", resultWord = "azdb"
Output: 2
Explanation:

By appending 'd' and 'b' to "azdb", we can transform it into a subsequence of "abcz".

Constraints:
    🐇
Thumbnail 0
Testcase

Result
Case 1

input:

output: