Dataford
Interview QuestionsInterview GuidesExperiencesMock InterviewsPricing
Get started

Unique Substring Sliding Window

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

Your question is Unique Substring Sliding Window. 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

Roblox experiences may analyze a player's chat message before displaying or processing it. Given a string message, find the length of the longest contiguous substring containing no repeated characters.

A substring must contain consecutive characters from message, and character comparisons are case-sensitive. For example, A and a are considered different characters.

Formal Specification

Implement longest_unique_substring(message).

  • Input: message, a string.
  • Output: An integer representing the maximum length of a contiguous substring in which every character appears once.
  • Return 0 when message is empty.

Constraints

  • 0 <= len(message) <= 100,000
  • message contains printable ASCII characters
  • The substring must be contiguous
  • Character comparisons are case-sensitive

Function Signature

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