IsIsogram Recursion

I have experience in Python and C#, so I decided to get fancy and use recursion for my isogram checking function.

bool UBullCowCartridge::IsIsogram(FString MyString) const
{
    if (MyString.Len() == 0)
    {
        return true;
    }
    for (int32 i = 1; i < MyString.Len(); i++)
    {
        if (MyString[0] == MyString[i])
        {
            return false;
        }
    }
    return IsIsogram(MyString.RightChop(1));
}
2 Likes

How did you figure out recursion?

I have a lot of experience programming in Python and then started learning C# about a year ago. Recursion was a white whale for me when I was first introduced to the concept, but since then I’ve found places where it makes more sense than something like a while loop. It’s very useful in search algorithms as most languages have a built in catch so you can’t go too deep before it stops you, therefore you never get stuck in an endless loop. However, depending on what you’re doing inside the function, you can eat up a lot of memory.

Privacy & Terms