Dataford
Interview QuestionsInterview GuidesExperiencesMock InterviewsPricing
Get started
String or Array Traversal
00:00
5 left

String or Array Traversal

MediumPython

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):
Interviewer

Your question is String or Array Traversal. Start with the requirements in the Question tab.

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.
CodePython 3
You need to log in / sign up to run or submit.Ln 2
Run your code to see test output here.