Given three strings. Check if the last string is a common subsequence of the first two

This has to be done in O(n) time. What should be the approach. Please share code

hello @anshufirefox

the idea is simple . iterate the last string.
and find its characters in both the strings.
ie first find the first character of last string ,then second then third so on.

string  we have a,b,c;
int i=0,j=0,k=0;
while(k<  c.size() ) {
      
while(i<a.size() && a[i]!=c[k] ) {   i++;}
while(j<b.size() && b[j]!=c[k]) {  j++; }
if(i==a.size() || j==b.size() )  break ; //character not found
k++;
}
if(k==c.size())
  present
else
not present

time complexity -> O( LENGTH A + LENGTH B + LENGTH C)