Created
September 3, 2015 18:16
-
-
Save agr-shrn/a730428165a45323efd3 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#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