PracHub
QuestionsPremiumCoachesLearningGuidesInterview Prep
|Home/Coding & Algorithms/TikTok

Find longest substring without repeating characters

Last updated: Mar 29, 2026

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.

Related Interview Questions

  • Parse a nested list from a string - TikTok (medium)
  • Implement stacks, streaming median, and upward path sum - TikTok (easy)
  • Solve common string/DP/stack problems - TikTok (medium)
  • Find the longest palindromic substring - TikTok (easy)
  • Implement stack variants and path-sum check - TikTok (medium)
TikTok logo
TikTok
Sep 29, 2025, 12:00 AM
Machine Learning Engineer
Onsite
Coding & Algorithms
2
0

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).

Submit Your Answer to Earn 20XP

Sign in to leave a comment

Loading comments...

Browse More Questions

More Coding & Algorithms•More TikTok•More Machine Learning Engineer•TikTok Machine Learning Engineer•TikTok Coding & Algorithms•Machine Learning Engineer Coding & Algorithms
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
  • Compare Platforms
  • Discord Community

Support

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

Legal

  • Privacy Policy
  • Terms of Service
  • About Us

© 2026 PracHub. All rights reserved.