PracHub
QuestionsPremiumCoachesLearningGuidesInterview Prep
|Home/Coding & Algorithms/Bytedance

Implement several OA simulation problems

Last updated: Mar 29, 2026

Quick Overview

This set of problems evaluates skills in string processing, memory simulation and allocation logic, and online data-structure maintenance for dynamic contiguous segment counting, testing algorithmic design and attention to stateful invariants.

  • easy
  • Bytedance
  • Coding & Algorithms
  • Data Scientist

Implement several OA simulation problems

Company: Bytedance

Role: Data Scientist

Category: Coding & Algorithms

Difficulty: easy

Interview Round: Take-home Project

Reconstruct and solve the following coding problems from an online assessment. 1. **Case-insensitive adjacent differences** Given a string `s`, treat uppercase and lowercase letters as the same. Count how many indices `i` with `0 <= i < len(s) - 1` satisfy `lower(s[i]) != lower(s[i + 1])`. 2. **Memory allocator with 8-aligned starts** You are given an initial binary array `memory[0..n-1]`, where `0` means free and `1` means occupied. Support two operations: - `alloc(x)`: find the leftmost start index `s` such that `s % 8 == 0`, `s + x <= n`, and every value in `memory[s..s+x-1]` is `0`. Allocate that entire block to a newly created allocation ID, and mark all those cells as occupied by the same ID. If no such block exists, report failure. - `erase(id)`: free every cell currently assigned to `id` by setting it back to `0`. If `id` does not exist or has already been erased, report failure. Implement a simulator for these operations. 3. **Online counting of same-color contiguous segments** Points lie on integer positions of a line. Each update assigns or changes the color of one point. After every update, return the current number of contiguous segments, where a segment is a maximal run of adjacent positions with the same color. Only colored positions participate; a missing position breaks continuity. Design an efficient online method to maintain the segment count as points are inserted or recolored.

Quick Answer: This set of problems evaluates skills in string processing, memory simulation and allocation logic, and online data-structure maintenance for dynamic contiguous segment counting, testing algorithmic design and attention to stateful invariants.

Related Interview Questions

  • Reverse Nodes in K-Sized Groups - Bytedance
  • Solve Bracket Matching and Tree Width - Bytedance (hard)
  • Reverse Linked List Groups - Bytedance (medium)
  • Solve Stack and String Shift Problems - Bytedance (medium)
  • Find LCA With Parent Pointers - Bytedance (medium)
Bytedance logo
Bytedance
Mar 5, 2026, 12:00 AM
Data Scientist
Take-home Project
Coding & Algorithms
1
0

Reconstruct and solve the following coding problems from an online assessment.

  1. Case-insensitive adjacent differences
    Given a string s , treat uppercase and lowercase letters as the same. Count how many indices i with 0 <= i < len(s) - 1 satisfy lower(s[i]) != lower(s[i + 1]) .
  2. Memory allocator with 8-aligned starts
    You are given an initial binary array memory[0..n-1] , where 0 means free and 1 means occupied. Support two operations:
    • alloc(x) : find the leftmost start index s such that s % 8 == 0 , s + x <= n , and every value in memory[s..s+x-1] is 0 . Allocate that entire block to a newly created allocation ID, and mark all those cells as occupied by the same ID. If no such block exists, report failure.
    • erase(id) : free every cell currently assigned to id by setting it back to 0 . If id does not exist or has already been erased, report failure.
    Implement a simulator for these operations.
  3. Online counting of same-color contiguous segments
    Points lie on integer positions of a line. Each update assigns or changes the color of one point. After every update, return the current number of contiguous segments, where a segment is a maximal run of adjacent positions with the same color. Only colored positions participate; a missing position breaks continuity. Design an efficient online method to maintain the segment count as points are inserted or recolored.

Submit Your Answer

Sign in to leave a comment

Loading comments...

Browse More Questions

More Coding & Algorithms•More Bytedance•More Data Scientist•Bytedance Data Scientist•Bytedance Coding & Algorithms•Data Scientist Coding & Algorithms
PracHub

Master your tech interviews with 8,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.