PracHub
QuestionsPremiumLearningGuidesInterview PrepNEWCoaches
|Home/Coding & Algorithms/Microsoft

Find longest substring without repeating characters

Last updated: Mar 29, 2026

Quick Overview

This question evaluates a candidate's skills in string manipulation, algorithm design, and reasoning about time and space complexity when identifying maximal contiguous substrings with distinct characters.

  • medium
  • Microsoft
  • Coding & Algorithms
  • Software Engineer

Find longest substring without repeating characters

Company: Microsoft

Role: Software Engineer

Category: Coding & Algorithms

Difficulty: medium

Interview Round: Technical Screen

## Problem Given a string `s`, return the length of the longest contiguous substring that contains no repeated characters. ### Input - `s`: a string (may contain letters, digits, symbols, and spaces). ### Output - An integer: the maximum length of a substring of `s` with all distinct characters. ### Examples - Input: `"abcabcbb"` → Output: `3` (e.g., `"abc"`) - Input: `"bbbbb"` → Output: `1` (e.g., `"b"`) - Input: `"pwwkew"` → Output: `3` (e.g., `"wke"`) ### Constraints (typical) - `0 <= len(s) <= 2 * 10^5` ### Notes - The substring must be contiguous (not a subsequence).

Quick Answer: This question evaluates a candidate's skills in string manipulation, algorithm design, and reasoning about time and space complexity when identifying maximal contiguous substrings with distinct characters.

Related Interview Questions

  • Return Top K Open Businesses - Microsoft (hard)
  • Implement Memory Allocation and In-Memory Records - Microsoft (medium)
  • Implement K-Means and Detect Divisible Subarrays - Microsoft (medium)
  • Sort Three Categories In Place - Microsoft (medium)
  • Retain Top K Elements - Microsoft (medium)
Microsoft logo
Microsoft
Nov 25, 2025, 12:00 AM
Software Engineer
Technical Screen
Coding & Algorithms
2
0

Problem

Given a string s, return the length of the longest contiguous substring that contains no repeated characters.

Input

  • s : a string (may contain letters, digits, symbols, and spaces).

Output

  • An integer: the maximum length of a substring of s with all distinct characters.

Examples

  • Input: "abcabcbb" → Output: 3 (e.g., "abc" )
  • Input: "bbbbb" → Output: 1 (e.g., "b" )
  • Input: "pwwkew" → Output: 3 (e.g., "wke" )

Constraints (typical)

  • 0 <= len(s) <= 2 * 10^5

Notes

  • The substring must be contiguous (not a subsequence).

Comments (0)

Sign in to leave a comment

Loading comments...

Browse More Questions

More Coding & Algorithms•More Microsoft•More Software Engineer•Microsoft Software Engineer•Microsoft Coding & Algorithms•Software Engineer Coding & Algorithms
PracHub

Master your tech interviews with 7,500+ real questions from top companies.

Product

  • Questions
  • Learning Tracks
  • Interview Guides
  • Resources
  • Premium
  • For Universities
  • Student Access

Browse

  • By Company
  • By Role
  • By Category
  • Topic Hubs
  • SQL Questions
  • Compare Platforms
  • Discord Community

Support

  • support@prachub.com
  • (916) 541-4762

Legal

  • Privacy Policy
  • Terms of Service
  • About Us

© 2026 PracHub. All rights reserved.