Advertisement
STANAANDREY

issubstr

Oct 3rd, 2019
240
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.40 KB | None | 0 0
  1. inline bool issubstr(string t, string ss)
  2. {
  3.     if (t == ss)
  4.         return true;
  5.  
  6.     int lt, lss;
  7.     lt = t.size();
  8.     lss = ss.size();
  9.  
  10.     if (lss > lt)
  11.         return false;
  12.  
  13.     int j = 0;
  14.     for (int i = 0; i < lt && j < lss && lss - j <= lt - i; i++)
  15.         {
  16.             if (ss[j] == t[i])
  17.                 j++;
  18.         }
  19.     if (j == lss)
  20.         return true;
  21.     return false;
  22. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement