Dataford
Interview QuestionsInterview GuidesExperiencesMock InterviewsPricing
Get started
Unique Character Coding
00:00
5 left

Unique Character Coding

EasyPython

Problem

Given a string, find the first character that is unique, meaning it appears only once.

Implement first_unique_char(s) to return the character itself. Return an empty string if no character appears exactly once. Treat characters according to Python string iteration.

Signature: def first_unique_char(s):

Constraints

  • 0 <= len(s) <= 10^5
  • s may contain any characters supported by Python strings
  • Return the character itself, not its index
  • Return an empty string when no unique character exists

Function Signature

def first_unique_char(s):
Interviewer

Your question is Unique Character Coding. Start with the requirements in the Question tab.

Run and submit as often as you like. When you're ready, talk me through your approach or go straight to the code.

You need to log in / sign up to run or submit.
CodePython 3
You need to log in / sign up to run or submit.Ln 2
Run your code to see test output here.