IsIsogram() function

This is my solution for the 46 lecture.

bool FBullCowGame::IsIsogram(FString Word) const
{
// treat 0 and 1 letter words as isograms
if (Word.length() <= 1) { return true; }

TMap<char, bool> LetterSeen; // setup our map
for (auto Letter : Word) // for all letters of the word
{
	Letter = tolower(Letter); // to handle mixed case 
	// loop trough all the letters of the word
			// if the letter is in the map
			if (LetterSeen[Letter])
			{
				return false;	// we do NOT have an asogram
			}
			else
			{
				LetterSeen[Letter] = true; // add the letter to the map as seen
			}
}
return true; // for example in case where /0 is entered

}

Privacy & Terms