Check whether two strings contain same characters in same order |  ; if length of the b = 0 then we return true ; if length of a = 0 that means b is not present in a so we return false ; Driver code
#include <iostream> NEW_LINE using namespace std ; bool checkSequence ( string a , string b ) { if ( b . size ( ) == 0 ) return true ; if ( a . size ( ) == 0 ) return false ; if ( a [ 0 ] == b [ 0 ] ) return checkSequence ( a . substr ( 1 ) , b . substr ( 1 ) ) ; else return checkSequence ( a . substr ( 1 ) , b ) ; } int main ( ) { string s1 = " Geeks " , s2 = " Geks " ; if ( checkSequence ( s1 , s2 ) ) cout << " Yes " ; else cout << " No " ; }