Dataford
Interview QuestionsInterview GuidesExperiencesMock InterviewsPricing
Get started

Unique Characters Function

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

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

Cvent event administrators may define a compact event code for internal workflows. Write a function that returns whether every character in an event code appears exactly once.

Formal Specification

Implement has_all_unique_characters(code).

  • Input: code, a Python string.
  • Output: Return True if no character occurs more than once. Otherwise, return False.
  • Character comparisons are case-sensitive. For example, A and a are different characters.
  • Spaces and punctuation are characters and must also be unique if present.

Constraints

  • 0 <= len(code) <= 100,000
  • code may contain any Python string characters, including Unicode
  • Character comparisons are case-sensitive
  • Spaces and punctuation count as characters

Function Signature

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