My answer for the challenge in 67- Checking Characters Part 2 was a bit different than the answer provided after the challenge and I want to find out why as I was not sure of my answer even though it appears to work fine.
The solution offered after the challenge seems to disagree with what I thought would happen.
I know there are multiple ways to do things but I have no prior experience and want to know why it works.
Thank you!
bool UBullCowCartridge::IsIsogram(FString Word) const
{
// for(int32 Index = 0, Comparison = Index + 1; Comparison < Word.Len(); Comparison++)
// {
// for(int32 Comparison = Index + 1; Comparison < Word.Len(); Comparison++)
// {
// if (Word[Index] == Word[Comparison])
// {
// return false;
// }
// }
// }
for(int32 Index = 0, Comparison = Index + 1; Comparison < Word.Len(); Comparison++)
{
for(Index = 1; Comparison < Word.Len(); Comparison++)
{
if (Word[Index] == Word[Comparison])
{
return false;
}
}
}
return true;
}