Created
September 17, 2014 12:55
-
-
Save kg86/d9fc55f2f0d169a3dfbf 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
class EasyConversionMachine { | |
public: | |
string isItPossible(string originalWord, string finalWord, int k) { | |
string POSSIBLE = "POSSIBLE"; | |
string INPOSSIBLE = "IMPOSSIBLE"; | |
int n = originalWord.size(); | |
int i; | |
int diff=0; | |
for(i = 0; i < n; i++){ | |
if (originalWord[i] != finalWord[i]) diff++; | |
} | |
if(diff <= k && (((k-diff) % 2) == 0)) return POSSIBLE; | |
else return INPOSSIBLE; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment