Dataford
Interview QuestionsInterview GuidesExperiencesMock InterviewsPricing
Get started
Classic Arrays or Strings Algorithm
00:00
5 left

Classic Arrays or Strings Algorithm

MediumPython

Problem

Tech(x) Preview displays a continuous segment of user-visible text in its compact interface. Given a string s, return the length of the longest substring containing no repeated characters.

A substring must use consecutive characters from s. Characters are case-sensitive, so A and a are different.

Formal Specification

Implement length_of_longest_substring(s), where s is a string. Return an integer representing the maximum length of any substring with all unique characters.

Constraints

  • 0 <= len(s) <= 5 * 10^4
  • s contains printable ASCII characters
  • Characters are case-sensitive
  • Return 0 for an empty string

Function Signature

def length_of_longest_substring(s):
Interviewer

Your question is Classic Arrays or Strings Algorithm. 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.