My IsIsogram() integration

Here is my implementation of the IsIsogram() method:

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); // handle mixed case
	    if (LetterSeen[Letter]) { // if the letter is in the map
		    return false; // we do NOT have an isogram
	    else { // otherwise
		    LetterSeen[Letter] = true; // add the letter to the map as seen
    return true; // completed the loop without any issues, which  means we DO have an isogram

I did it with the knowledge I have, rather than searching things up. I think I did well. :stuck_out_tongue:

EDIT: turns out I did exactly the same as Ben. The only difference is that I left some comments in and added another one for clarification. But it’s already obvious what’s going on, so I can remove the comments now…

Privacy & Terms