Mark As Completed Discussion

Good morning! Here's our prompt for today.

You're given a string of random alphanumerical characters with a length between 0 and 1000.

Write a method to return the first character in the string that does not repeat itself later on.

Description

So if we had a string input of "asdfsdafdasfjdfsafnnunl'", we can see there are multiple letters that are repeated.

Executing firstNonRepeat('asdfsdafdasfjdfsafnnunl') should return 'j' since it's the first letter where there is no duplicate.

Constraints

  • The given string can be empty
  • The string will only contain lowercase/uppercase alphabets and numerals
  • Expected time complexity : O(n)
  • Expected space complexity : O(A) where A is the number of ASCII characters

Try to solve this here or in Interactive Mode.

How do I practice this challenge?

PYTHON
OUTPUT
:001 > Cmd/Ctrl-Enter to run, Cmd/Ctrl-/ to comment

Here's how we would solve this problem...

How do I use this guide?

Access all course materials today

The rest of this tutorial's contents are only available for premium members. Please explore your options at the link below.

Returning members can login to stop seeing this.