My implementation. I haven’t used the Index and Comparison variables as the Word array subscripts. For a nested loop like this, I think the simple i and j work fine. They are declared in the scope of the ‘for loops’ so quite self-contained. Also as the statements inside the ‘for loops’ are single statements the use of the { and } also detract from the readability of the code.
I also stored the length of the Word rather than call the len() in the ‘for loop’. Not sure if this gives any performance benefits or not.
bool UBullCowCartridge::IsIsogram(const FString& Word) const
{
int32 WordLength = Word.Len();
for (int32 i = 0; i + 1 < WordLength; i++)
for (int32 j = i + 1; j < WordLength; j++)
if (Word[i] == Word[j])
return false;
return true;
}