knakul853

Untitled

Jul 20th, 2020
202
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.33 KB | None | 0 0
  1. class Solution {
  2. public:
  3.     int strStr(string a, string b) {
  4.        
  5.         int n = a.length();
  6.         int m = b.length();
  7.        
  8.         for(int i=0;i<n-m+1;i++){
  9.            
  10.             if(b==a.substr(i,m)){
  11.                 return i;
  12.             }
  13.            
  14.         }
  15.         return -1;
  16.        
  17.     }
  18. };
Add Comment
Please, Sign In to add comment