Skip to content

Instantly share code, notes, and snippets.

@agr-shrn
Created September 3, 2015 18:16
Show Gist options
  • Save agr-shrn/a730428165a45323efd3 to your computer and use it in GitHub Desktop.
Save agr-shrn/a730428165a45323efd3 to your computer and use it in GitHub Desktop.
#include <iostream>
#include <String>
using namespace std ;
bool issubstring ( string S1 , string S2 ) {
if ( (S1.find ( S2 )) != string :: npos ) return true ;
else return false ;
}
bool isRotation ( string S1 , string S2 ) {
if ( (S1 . length ()) != S2 . length () || S1 . length () <= 0 )
return false ;
return issubstring ( S1 + S1 , S2 );
}
int main () {
string S1 = "apple" ;
string S2 = "pleap" ;
cout << isRotation ( S1 , S2 ) << endl ;
// cout << endl << String :: npos;
return 0 ;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment