Skip to content

Instantly share code, notes, and snippets.

@kg86
Created September 17, 2014 12:55
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save kg86/d9fc55f2f0d169a3dfbf to your computer and use it in GitHub Desktop.
Save kg86/d9fc55f2f0d169a3dfbf to your computer and use it in GitHub Desktop.
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