PracHub
QuestionsPremiumCoachesLearningGuidesInterview Prep
|Home/Coding & Algorithms/Twitch

Solve four design-leaning coding problems

Last updated: Mar 29, 2026

Quick Overview

This multi-part question evaluates algorithmic problem-solving, data structure design and manipulation (such as LRU cache semantics), stateful simulation and scoring logic, chronological quota accounting for billing, and set/map operations for detecting overlaps.

  • medium
  • Twitch
  • Coding & Algorithms
  • Software Engineer

Solve four design-leaning coding problems

Company: Twitch

Role: Software Engineer

Category: Coding & Algorithms

Difficulty: medium

Interview Round: Onsite

You are given four independent interview-style coding tasks. For each task, implement the requested function/class with clear inputs/outputs and reasonable constraints. (You do **not** need to integrate the tasks together.) ## 1) Rock–Paper–Scissors scoring with bonuses Design a small game engine that computes the score for a sequence of Rock–Paper–Scissors rounds. ### Rules - Each round has two moves: `playerMove` and `opponentMove`, each in `{R, P, S}`. - Outcome: - Win: player gets `+1` point - Tie: player gets `0` points - Loss: player gets `0` points - Bonus A (win streak): if the player wins **two or more rounds in a row**, then **each** win after the first consecutive win gets an **extra +1**. - Example: outcomes `W, W, W` yields base `1+1+1` plus streak bonus `0+1+1`. - Bonus B (break a tie): if the previous round was a **tie** and the current round is a **win**, the current round gets an **extra +1**. ### Requirements Given a list of rounds in chronological order, return: 1. The total score for the whole sequence. 2. The score earned **per round** (after bonuses). ### Input/Output - Input: `rounds = [(playerMove1, oppMove1), ..., (playerMoveN, oppMoveN)]` - Output: `(totalScore, perRoundScores)` Constraints: `1 <= N <= 2e5`. --- ## 2) LRU cache API Implement an in-memory cache with **Least Recently Used (LRU)** eviction. ### Requirements Implement a class with: - `LRUCache(capacity)` - `get(key) -> value | -1` (returns `-1` if not found) - `put(key, value)` Rules: - When the cache exceeds `capacity`, evict the **least recently used** key. - Any successful `get` makes that key the most recently used. - `put` of an existing key updates its value and makes it most recently used. - Target complexity: `O(1)` average time per operation. ### Follow-up (thread safety) Describe how you would make this cache safe under concurrent access from multiple threads (you do not need to implement concurrency primitives unless explicitly asked). --- ## 3) 24-hour notification billing with a daily free quota A notification service charges based on the number of notifications sent each hour of a day (24 hours total). ### Inputs - `counts[24]`: integer array where `counts[i]` is the number of notifications sent during hour `i`. - `freeLimit`: total number of notifications per day that are free. - `unitPrice`: cost per notification beyond the free limit. ### Billing rule - The `freeLimit` is applied **chronologically** from hour `0` to hour `23` (first-come-first-served). - For each hour, some portion of that hour’s notifications may be free until the daily `freeLimit` is exhausted. ### Output Return: 1. `totalCost` for the day. 2. `hourlyCost[24]` where `hourlyCost[i]` is the cost charged for hour `i`. Constraints: `0 <= counts[i] <= 1e9`, `0 <= freeLimit <= 1e12`, `0 <= unitPrice <= 1e6`. --- ## 4) Find channels with overlapping followers You are given a mapping from channels to their followers. ### Input - `channelToFollowers`: map/dictionary where `channelToFollowers[channel]` is a list (or set) of follower IDs. - `targetChannel`: a channel name that exists in the map. ### Task Return all **other** channels that share **at least one** follower with `targetChannel`. ### Output Return a list of channels (excluding `targetChannel`) that overlap. ### Follow-ups - How would you optimize if you need to answer many queries for different `targetChannel` values? - What is the time/space complexity of your approach? Constraints (suggested): up to `1e5` channels, total follower memberships up to `1e6`.

Quick Answer: This multi-part question evaluates algorithmic problem-solving, data structure design and manipulation (such as LRU cache semantics), stateful simulation and scoring logic, chronological quota accounting for billing, and set/map operations for detecting overlaps.

Twitch logo
Twitch
Oct 26, 2025, 12:00 AM
Software Engineer
Onsite
Coding & Algorithms
9
0

You are given four independent interview-style coding tasks. For each task, implement the requested function/class with clear inputs/outputs and reasonable constraints. (You do not need to integrate the tasks together.)

1) Rock–Paper–Scissors scoring with bonuses

Design a small game engine that computes the score for a sequence of Rock–Paper–Scissors rounds.

Rules

  • Each round has two moves: playerMove and opponentMove , each in {R, P, S} .
  • Outcome:
    • Win: player gets +1 point
    • Tie: player gets 0 points
    • Loss: player gets 0 points
  • Bonus A (win streak): if the player wins two or more rounds in a row , then each win after the first consecutive win gets an extra +1 .
    • Example: outcomes W, W, W yields base 1+1+1 plus streak bonus 0+1+1 .
  • Bonus B (break a tie): if the previous round was a tie and the current round is a win , the current round gets an extra +1 .

Requirements

Given a list of rounds in chronological order, return:

  1. The total score for the whole sequence.
  2. The score earned per round (after bonuses).

Input/Output

  • Input: rounds = [(playerMove1, oppMove1), ..., (playerMoveN, oppMoveN)]
  • Output: (totalScore, perRoundScores)

Constraints: 1 <= N <= 2e5.

2) LRU cache API

Implement an in-memory cache with Least Recently Used (LRU) eviction.

Requirements

Implement a class with:

  • LRUCache(capacity)
  • get(key) -> value | -1 (returns -1 if not found)
  • put(key, value)

Rules:

  • When the cache exceeds capacity , evict the least recently used key.
  • Any successful get makes that key the most recently used.
  • put of an existing key updates its value and makes it most recently used.
  • Target complexity: O(1) average time per operation.

Follow-up (thread safety)

Describe how you would make this cache safe under concurrent access from multiple threads (you do not need to implement concurrency primitives unless explicitly asked).

3) 24-hour notification billing with a daily free quota

A notification service charges based on the number of notifications sent each hour of a day (24 hours total).

Inputs

  • counts[24] : integer array where counts[i] is the number of notifications sent during hour i .
  • freeLimit : total number of notifications per day that are free.
  • unitPrice : cost per notification beyond the free limit.

Billing rule

  • The freeLimit is applied chronologically from hour 0 to hour 23 (first-come-first-served).
  • For each hour, some portion of that hour’s notifications may be free until the daily freeLimit is exhausted.

Output

Return:

  1. totalCost for the day.
  2. hourlyCost[24] where hourlyCost[i] is the cost charged for hour i .

Constraints: 0 <= counts[i] <= 1e9, 0 <= freeLimit <= 1e12, 0 <= unitPrice <= 1e6.

4) Find channels with overlapping followers

You are given a mapping from channels to their followers.

Input

  • channelToFollowers : map/dictionary where channelToFollowers[channel] is a list (or set) of follower IDs.
  • targetChannel : a channel name that exists in the map.

Task

Return all other channels that share at least one follower with targetChannel.

Output

Return a list of channels (excluding targetChannel) that overlap.

Follow-ups

  • How would you optimize if you need to answer many queries for different targetChannel values?
  • What is the time/space complexity of your approach?

Constraints (suggested): up to 1e5 channels, total follower memberships up to 1e6.

Submit Your Answer

Sign in to leave a comment

Loading comments...

Browse More Questions

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