Created
August 31, 2014 08:27
-
-
Save kg86/81b9109370c182cbd6a6 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 BallAndHats | |
{ | |
public: | |
int getHat(string hats, int numSwaps) | |
{ | |
int idx = hats.find("o"); | |
if (numSwaps == 0) return idx; | |
return (idx + (numSwaps % 2)) % 2; | |
} | |
}; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment