[TikTok] OA 2025 start – 12 Mar (generic)
  1. Event Scheduling System with Priority Queue

An event management company needs a scheduling system to prioritize optimizing events based on their urgency. Events are added dynamically, and the system must be able to efficiently remove and process the highest-priority event at any time without re-sorting.

Pick ONE option:

  • Option 1: Initialize array events
    • If a new event arrives, sort by ascending order
    • If an event needs to be processed and the array is not empty:
      • Remove the least element of the array
      • Process event
  • Option 2: Initialize stack events
    • Push event to stack
    • If an event needs to be processed and the stack is not empty:
      • Pop the most recent event
      • Process event
  • Option 3: Initialize priority queue events
    • For each event arrival:
      • Insert event into a priority queue with priority as key
    • If an event needs to be processed and the priority queue is not empty:
      • Remove the event with the highest priority
      • Process event

  1. Customer Service System with a Circular Queue

A customer service center needs to manage incoming calls in a circular queue to handle a limited number of lines. When the queue is full, new calls must wait until a line is free.

Pick ONE option:

  • Option 1: Initialize an array queue with fixed size
    • Enqueue new call to end of queue
    • If the queue is full:
      • Discard the oldest call
  • Option 2: Initialize an array queue with fixed size
    • Enqueue new call at next position modulo queue size
    • If the queue is full:
      • Wait until the queue has space
  • Option 3: Initialize a linked list queue
    • Enqueue new call to the end of the list
    • If the queue is full:
      • Remove the first element in the list
  • Option 4: Initialize stack calls
    • Push new call to stack
    • If the stack is full:
      • Pop the oldest call from the stack

  1. TikTok Viral Campaign

TikTok is a widely used social media platform where users follow influencers who shape their content preferences. If user A follows user B, then A is said to be influenced by B. Once a user is influenced, they immediately propagate this information to all users who follow them.

As a brand manager designing a viral campaign, your goal is to determine the minimum number of users who need to be initially seeded with the trend so that the information eventually reaches every user on the platform. If a user is neither an influencer nor a follower, they are still a TikTok user and must be directly introduced to the viral campaign if needed.

You are given an integer n, representing the total number of TikTok users, along with two lists: influencers and followers—each of size n.

  • influencers[i] represents an influencer.
  • followers[i] represents the user who follows that influencer.
  • If followers[i] = -1, it indicates that the corresponding influencer has no followers.

Important Notes:

  1. Some users may not have followers (followers[i] = -1), meaning they are not followed by anyone.
  2. There may be mutual follow relationships (A follows B and B follows A).
  3. Some users might appear in influencers but not in followers (meaning they follow nobody).
  4. Some users might appear in neither influencers nor followers, meaning they are TikTok users but do not follow or influence anyone.

Goal:

Compute the minimum set of users to whom the trend should be initially introduced, ensuring that the trend reaches every user.

Example

n = 4  
influencers = [2, 1, 3, 4]  
followers = [1, 3, 2, -1]  
  • Introduce the viral trend to user 4.
  • User 4 influences User 1.
  • User 1 influences User 3.
  • User 3 influences User 2.
  • User 2 influences User 3.

Thus, the trend spreads to all users. The minimum number of users required to initiate the trend is 1 (introducing it to User 4).


  1. TikTok Content Clustering

TikTok delivers video content to users optimally. The system has a sequence of n video chunks represented by an array of integers, videoChunks, where videoChunks[i] represents a chunk with an associated delivery cost ci (e.g., video quality, network usage, server load).

The task is to partition the sequence of video chunks into exactly k non-empty groups so that the total cost of all the groups is minimized. The cost of a group (subarray) is defined as the sum of the costs of its first and last chunk in that group.

Example

n = 5  
videoChunks = [7, 8, 3, 9, 6]  
k = 2  

An optimal way to divide the array into two subarrays:

  • [7, 8], [3, 9, 6]
  • Cost of first subarray = 7 + 8 = 15
  • Cost of second subarray = 3 + 6 = 9
  • Total cost = 15 + 9 = 24

It can be proven that the minimum possible total cost is 24.

Function Description

Complete the function getMinimumTotalCost in the editor below.

Parameters:

  • int videoChunks[n]: representing video chunk costs.
  • int k: representing the number of partitions.

Returns:

  • long: representing the minimum possible total cost to partition into non-empty groups.

Constraints:

  • 1 ≤ n ≤ 10⁵
  • 1 ≤ videoChunks[i] ≤ 10⁹
  • 1 ≤ k ≤ n

我们长期稳定承接各大科技公司如TikTok、Google、Amazon等的OA笔试代写服务,确保满分通过。如有需求,请随时联系我们。

We consistently provide professional online assessment services for major tech companies like TikTok, Google, and Amazon, guaranteeing perfect scores. Feel free to contact us if you're interested.

Leave a Reply

Your email address will not be published. Required fields are marked *