Dataford
Interview QuestionsInterview GuidesExperiencesMock InterviewsPricing
Get started

String Unique Characters

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

Your question is String Unique Characters. 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

J.B. Hunt 360 may receive shipment reference strings from multiple operational workflows. Implement a function that determines whether a string contains only unique characters.

Treat characters as distinct based on their exact values. The comparison is case-sensitive, so A and a are different characters. Spaces, punctuation, digits, and other characters must also be checked. Return True when no character appears more than once, and return False as soon as a duplicate is found.

Formal Specification

Given one string s, return a boolean:

  • True if every character in s occurs exactly once or the string is empty.
  • False if any character occurs more than once.

Do not modify the input string.

Constraints

  • 0 <= len(s) <= 10^5
  • The input may contain letters, digits, whitespace, punctuation, and Unicode characters
  • Character comparison is case-sensitive

Function Signature

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