Dataford
Interview QuestionsInterview GuidesExperiencesMock InterviewsPricing
Get started

Debugging Approach

EasyPython00:00
Practice interviewer
In session
5 left
00:00

Your question is Debugging Approach. Start with the requirements on the right.

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.

Problem

Discuss how you would approach debugging a piece of code.

For the practical portion, debug the implementation so it returns the index of the first character that appears exactly once. Use -1 when no unique character exists.

Function signature: def first_unique_char(text):. Input is a string, and output is an integer index.

Constraints

  • 0 <= len(text) <= 10^5
  • text contains ordinary Unicode characters
  • Return the lowest index whose character occurs exactly once
  • Return -1 when no character is unique

Function Signature

def first_unique_char(text):
Your solutionPython 3
You need to log in / sign up to run or submit.
Run your code to see test output