diff --git a/2486. Append Characters to String to Make Subsequence b/2486. Append Characters to String to Make Subsequence new file mode 100644 index 0000000..ab0c3a1 --- /dev/null +++ b/2486. Append Characters to String to Make Subsequence @@ -0,0 +1,18 @@ +class Solution { +public: + int appendCharacters(string s, string t) { + int i = 0, j = 0; + int len_s = s.size(), len_t = t.size(); + + // Traverse both strings + while (i < len_s && j < len_t) { + if (s[i] == t[j]) { + j++; + } + i++; + } + + // The characters that need to be appended + return len_t - j; + } +};