Dataford
Interview QuestionsInterview GuidesExperiencesMock InterviewsPricing
Get started

Longest Unique Message Substring

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

Your question is Longest Unique Message Substring. 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

In Providence messaging and note-entry surfaces, repeated characters can appear in free-text input. Write a function that returns the length of the longest substring in a string s that contains no repeated characters.

Formal Specification

  • Input: a string s
  • Output: an integer representing the maximum length of any contiguous substring of s with all unique characters

A substring must be contiguous. The function should run efficiently for large inputs.

Constraints

  • 0 <= len(s) <= 10^5
  • s consists of printable characters, including spaces and symbols
  • Return the length of the longest valid substring

Function Signature

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