➜ ~

Playing Hacks and Stuffs!


Project maintained by h4ckyou Hosted on GitHub Pages — Theme by mattgraham

First Letter to Appear Twice

image

So we’re to find the first letter that appears twice

At first I was wrapping my head trying to understand the first example to come up with a solution but then I figured that way is just me overdoing it

So instead I’ll go with a more better approach that involves the user of Set Data Structure

The idea is I’ll iterate through each character in the string then I’ll add the characters on each iteration to the set

When I come across a reptition of a character then that’s the first letter appearing twice which i’ll return

Here’s my solve script: link image