Dataford
Interview QuestionsInterview GuidesExperiencesMock InterviewsPricing
Get started

String or Array Traversal

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

Your question is String or Array Traversal. 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

OfferUp can analyze listing titles to identify the longest segment containing no repeated characters. Given a string title, return the length of its longest substring with all distinct characters.

A substring must consist of consecutive characters. Characters are case-sensitive, so A and a are different.

Formal Specification

  • Input: A string title containing zero or more printable characters.
  • Output: An integer representing the maximum length of a substring with no repeated characters.

Constraints

  • 0 <= len(title) <= 10^5
  • title contains printable ASCII characters
  • Characters are case-sensitive
  • The input may be an empty string

Function Signature

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