We record the lengths of the strings \(s\) and \(t\) as \(n\) and \(m\), respectively. Then, we use two pointers \(i\) and \(j\) to point to the beginning of the strings \(s\) and \(t\), and use a boolean variable \(\textit{rem}\) to record whether a character has been removed.
Next, we start traversing the strings \(s\) and \(t\). If \(s[i]\) is not equal to \(t[j]\), we check if a character has already been removed. If a character has been removed, we exit the loop; otherwise, we mark that a character has been removed and skip \(s[i]\). Otherwise, we skip both \(s[i]\) and \(t[j]\). Continue traversing until \(i \geq n\) or \(j \geq m\).
Finally, return \(j\).
The time complexity is \(O(n+m)\), where \(n\) and \(m\) are the lengths of the strings \(s\) and \(t\), respectively.