PracHub
QuestionsPremiumLearningGuidesCheatsheetNEWCoaches
|Home/Coding & Algorithms/TikTok

Find longest substring with ≥k repeats

Last updated: Mar 29, 2026

Quick Overview

This question evaluates proficiency with string-processing techniques and character frequency analysis, focusing on algorithmic skills in the Coding & Algorithms domain. It is commonly asked to assess algorithmic reasoning about constraint handling, edge cases, and efficiency, and is positioned at the practical application level rather than purely conceptual understanding.

  • hard
  • TikTok
  • Coding & Algorithms
  • Software Engineer

Find longest substring with ≥k repeats

Company: TikTok

Role: Software Engineer

Category: Coding & Algorithms

Difficulty: hard

Interview Round: Technical Screen

## Problem You are given: - a string `s` (consisting of lowercase English letters), and - an integer `k`. Return the length of the **longest contiguous substring** of `s` such that **every distinct character** in that substring appears **at least `k` times** within the substring. If no such substring exists, return `0`. ## Input / Output - **Input:** `s`, `k` - **Output:** an integer length ## Constraints (typical interview bounds) - `1 <= |s| <= 10^4` - `1 <= k <= |s|` - `s` contains only `'a'`–`'z'` ## Examples 1. `s = "aaabb"`, `k = 3` → output `3` (substring: `"aaa"`) 2. `s = "ababbc"`, `k = 2` → output `5` (substring: `"ababb"`) 3. `s = "abcd"`, `k = 2` → output `0`

Quick Answer: This question evaluates proficiency with string-processing techniques and character frequency analysis, focusing on algorithmic skills in the Coding & Algorithms domain. It is commonly asked to assess algorithmic reasoning about constraint handling, edge cases, and efficiency, and is positioned at the practical application level rather than purely conceptual understanding.

Related Interview Questions

  • Parse a nested list from a string - TikTok (medium)
  • Implement stacks, streaming median, and upward path sum - TikTok (easy)
  • Maximize sum with no adjacent elements - TikTok (medium)
  • Implement stack variants and path-sum check - TikTok (medium)
  • Find the longest palindromic substring - TikTok (easy)
TikTok logo
TikTok
Jan 9, 2026, 12:00 AM
Software Engineer
Technical Screen
Coding & Algorithms
0
0
Loading...

Problem

You are given:

  • a string s (consisting of lowercase English letters), and
  • an integer k .

Return the length of the longest contiguous substring of s such that every distinct character in that substring appears at least k times within the substring.

If no such substring exists, return 0.

Input / Output

  • Input: s , k
  • Output: an integer length

Constraints (typical interview bounds)

  • 1 <= |s| <= 10^4
  • 1 <= k <= |s|
  • s contains only 'a' – 'z'

Examples

  1. s = "aaabb" , k = 3 → output 3 (substring: "aaa" )
  2. s = "ababbc" , k = 2 → output 5 (substring: "ababb" )
  3. s = "abcd" , k = 2 → output 0

Comments (0)

Sign in to leave a comment

Loading comments...

Browse More Questions

More Coding & Algorithms•More TikTok•More Software Engineer•TikTok Software Engineer•TikTok 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.