PracHub
QuestionsPremiumLearningGuidesInterview PrepNEWCoaches
|Home/Coding & Algorithms/TikTok

Find >n/3 elements in sorted array

Last updated: Mar 29, 2026

Quick Overview

This question evaluates understanding of frequency analysis in sorted arrays, combinatorial bounds on repeated elements, and algorithmic complexity constraints such as O(log n) time and O(1) extra space.

  • Medium
  • TikTok
  • Coding & Algorithms
  • Software Engineer

Find >n/3 elements in sorted array

Company: TikTok

Role: Software Engineer

Category: Coding & Algorithms

Difficulty: Medium

Interview Round: Technical Screen

Given a sorted (non-decreasing) integer array A of length n, return all distinct values that occur strictly more than n/3 times. Design an algorithm that runs in O(log n) time and uses O( 1) extra space. Answer the following: ( 1) Prove there can be at most two such values. ( 2) Describe how to choose candidate positions and confirm counts using binary searches (e.g., lower_bound/upper_bound). ( 3) Provide correctness and complexity analysis.

Quick Answer: This question evaluates understanding of frequency analysis in sorted arrays, combinatorial bounds on repeated elements, and algorithmic complexity constraints such as O(log n) time and O(1) extra space.

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
Sep 6, 2025, 12:00 AM
Software Engineer
Technical Screen
Coding & Algorithms
1
0

Given a sorted (non-decreasing) integer array A of length n, return all distinct values that occur strictly more than n/3 times. Design an algorithm that runs in O(log n) time and uses O(

  1. extra space. Answer the following: (
  2. Prove there can be at most two such values. (
  3. Describe how to choose candidate positions and confirm counts using binary searches (e.g., lower_bound/upper_bound). (
  4. Provide correctness and complexity analysis.

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.