PracHub
QuestionsCoachesLearningGuidesInterview Prep

Quick Overview

This question evaluates proficiency in string processing, duplicate-detection using appropriate data structures, and algorithmic complexity analysis within the Coding & Algorithms domain.

  • medium
  • TikTok
  • Coding & Algorithms
  • Machine Learning Engineer

Find longest substring without repeating characters

Company: TikTok

Role: Machine Learning Engineer

Category: Coding & Algorithms

Difficulty: medium

Interview Round: Onsite

## Problem Given a string `s`, find the length of the longest **contiguous substring** that contains **no repeated characters**. ### Input - A string `s` (may contain letters, digits, symbols, and spaces). ### Output - An integer: the maximum length among all substrings of `s` that have all unique characters. ### Examples 1. `s = "abcabcbb"` → output `3` (e.g., "abc") 2. `s = "bbbbb"` → output `1` (e.g., "b") 3. `s = "pwwkew"` → output `3` (e.g., "wke") ### Constraints (typical interview assumptions) - `0 ≤ len(s) ≤ 10^5` - Aim for an algorithm faster than `O(n^2)`. ### Notes - Substring must be contiguous (not a subsequence).

Quick Answer: This question evaluates proficiency in string processing, duplicate-detection using appropriate data structures, and algorithmic complexity analysis within the Coding & Algorithms domain.

Return the length of the longest contiguous substring with all unique characters.

Constraints

  • Inputs are Python literals matching the function signature.
  • Return a deterministic exact-match value.

Examples

Input: ('abcabcbb',)

Expected Output: 3

Explanation: Prompt example 1.

Input: ('bbbbb',)

Expected Output: 1

Explanation: Prompt example 2.

Input: ('pwwkew',)

Expected Output: 3

Explanation: Prompt example 3.

Input: ('',)

Expected Output: 0

Explanation: Empty string.

Hints

  1. Model object-style prompts as operation streams when needed.
  2. Handle empty and boundary cases before the main logic.
Last updated: Jun 27, 2026

Loading coding console...

PracHub

Master your tech interviews with 8,000+ 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
  • AI Coding 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.

Related Coding Questions

  • Parse a nested list from a string - TikTok (medium)
  • Implement stacks, streaming median, and upward path sum - TikTok (easy)
  • Implement stack variants and path-sum check - TikTok (medium)
  • Find the longest palindromic substring - TikTok (easy)
  • Maximize sum with no adjacent elements - TikTok (medium)