Test duration: 110 mins
Number of questions: 7
1. Task Scheduling (Priority Queue Implementation)
Description: In a task scheduling system, tasks have priorities, and the highest-priority tasks must be processed first. You need to implement a max-priority queue for inserting tasks and retrieving the highest-priority task.
Problem Statement: Which of the following pseudocode snippets correctly implements the insertion of a task into a max-priority queue?
2. Social Media Feed Ranking (Merge Sort Algorithm)
Description: You are working on a social media platform where posts need to be sorted by engagement (likes + comments). Due to the large number of posts, an efficient sorting algorithm is required.
Problem Statement: Implement a merge sort algorithm to rank posts by engagement. Identify the pseudocode that correctly implements the merge sort algorithm for sorting posts.
3. Inheritance and Polymorphism in a Content Management System (CMS)
Description: In a CMS, you are designing a hierarchy where different types of Content (e.g., Article, Video, Image) must implement a render()
method. Each type of content has a different way of rendering.
Problem Statement: Which OOP concept allows the CMS to handle content objects uniformly while allowing each content type to define its unique render()
behavior?
4. Interface vs Abstract Class in a Payment Gateway System
Description: You are designing a payment gateway system that supports multiple payment methods (e.g., CreditCard, PayPal). Each payment method must implement core functionalities like processPayment()
. Some payment methods may provide additional behavior.
Problem Statement: Which approach best fits the requirement to ensure that all payment methods implement core functionalities while allowing additional behaviors?
5. Composition vs Inheritance in a Travel Booking System
Description: You are designing a travel booking system where a Trip can consist of different components such as Flight, Hotel, and CarRental. Each of these components has its unique behaviors, but they are all part of a single trip.
Problem Statement: Which of the following OOP design choices best fits this requirement?
6. TikTok Reel Impact
In the dynamic landscape of TikTok, creators are in a constant race to boost their videos' engagement by leveraging new features that enhance their content.
Each creator starts with a set of m
videos, represented by initialReelImpacts
, which indicates the baseline popularity of each reel. For the next n
days, TikTok releases new trending features, represented by newReelImpacts
, with each feature offering an additional boost to the creator's existing reels.
Process for Each Day:
- The creator appends the new feature from
newReelImpacts[i]
(where0 ≤ i < n
) to their current reels. - The updated lineup of reels is reviewed, and the
k-th
most impactful reel is selected based on its popularity. - The impact value of this reel is added to the total impact score.
Note:
- The initial impact score of the creator is the
k-th
highest impact value from the initial set ofinitialReelImpacts
.
Example
Input:
m = 2
initialReelImpacts = [2, 3]
n = 3
newReelImpacts = [4, 5, 1]
k = 2
Explanation:
- The initial impact score is the
2nd
highest value ininitialReelImpacts = [2, 3]
.
Impact score = 2 - Over the next
n
days:- Day 1: Append
4
. Current reels:[2, 3, 4]
. The2nd
highest impact is3
.
Impact score = 2 + 3 = 5 - Day 2: Append
5
. Current reels:[2, 3, 4, 5]
. The2nd
highest impact is4
.
Impact score = 5 + 4 = 9 - Day 3: Append
1
. Current reels:[1, 2, 3, 4, 5]
. The2nd
highest impact is4
.
Impact score = 9 + 4 = 13
- Day 1: Append
Output:
Total Impact Score = 13
Function Description:
Complete the function getTotalImpact
in the editor below.
Parameters:
int initialReelImpacts[m]
: The impact of initialm
reels.int newReelImpacts[n]
: The impact of the newn
reels that appear one by one.int k
: The fixed choice made by the creator, representing the position of the most impactful reel selected.
Returns:
long
: The total impact achieved by the creator after incorporating all elements fromnewReelImpacts
.
Example Input/Output:
Example 1:
Input:
m = 2
initialReelImpacts = [2, 3]
n = 3
newReelImpacts = [4, 5, 1]
k = 2
Output:
13
4o
7. Maximize Throughput
In ByteDance's vast network of data centers, millions of interconnected servers process content requests, handle user interactions, and deliver data to users globally. Each server is part of a dynamic task execution flow, represented by an array serverTasks
, where each entry in the array indicates the next server in the chain that will handle a task.
Problem Description
Optimizing the data pipeline requires careful management of these task handoffs. Once a task is picked up by server i
, it triggers a dependency on server serverTasks[i]
, transferring the load there. However, this data transfer disables both servers i
and serverTasks[i]
from participating in any further task handoffs, as they are locked due to processing the current load.
Therefore, selecting the right servers and managing the chain reactions of these task handoffs is crucial for maximizing throughput.
- Each server at index
i
points to the next serverserverTasks[i]
, where the task is transferred. - Once this transfer occurs, both the sending server and the receiving server become unavailable for subsequent tasks.
- Your challenge is to select servers in such a way that maximizes the overall throughput score.
- The throughput score is determined by the sum of the indices of the servers where tasks are successfully handed off.
Task
Your task is to analyze this network of server-to-server task handoffs, navigate the dependencies, and determine the maximum possible throughput score that can be achieved by optimally choosing the task handoffs.
Input
Given the array serverTasks
, calculate the maximum throughput score achievable by performing these operations in the most efficient way.
Example
Input:
n = 3
serverTasks = [0, 1, 2]
Explanation:
- We first select the server at index 0. It points to itself (server 0), and its throughput is 0. So, the current total throughput is 0. Note that server 0 is now blocked.
- Next, we select the server at index 1. It points to itself (server 1), and its throughput is 1. So, the current total throughput becomes 0 + 1 = 1. Note that both servers 0 and 1 are now blocked.
- Then, we select the server at index 2. It points to itself (server 2), and its throughput is 2. So, the current total throughput becomes 0 + 1 + 2 = 3.
All servers are now blocked.
Output:
3
Function Description
Complete the function calculateMaxProcessingThroughput
.
Function Signature:
calculateMaxProcessingThroughput(serverTasks)
Parameters:
serverTasks[n]
: An array of integers where each element indicates the next server where the task is to be transferred.
Returns:
long
: The maximum throughput score achievable.
Constraints
- 1 ≤ n ≤ 200000
- 0 ≤ serverTasks[i] < n
Sample Input and Output
Sample Input 0:
3
serverTasks = [2, 1, 0]
Sample Output 0:
3
Sample Input 1:
4
serverTasks = [3, 0, 1, 2]
Sample Output 1:
6
Explanation for Input 1:
- The sequence
[3, 0, 1, 2]
allows for a total throughput score of 6.
Tips :After our CSoahelp expert team's research, it was found that the boundary values for this question7 were set incorrectly, and a few cases were unable to pass. This was due to the mistake of the question setter, and we have pointed out multiple TikTok OA question errors, so we have confidence in this. Here is a suggestion for readers to start completing this OA next week, otherwise they will become victims of the wrong question
The original description contains an inaccuracy regarding the behavior of the receiving server during task handoffs. It states that
"Once this transfer occurs, both the sending server and the receiving server become unavailable for subsequent tasks."
However, this is incorrect because only the sending server becomes unavailable, while the receiving server remains available to handle new tasks. This correction ensures that the task execution logic aligns with the intended behavior.We can modify it to the following description
"Once this transfer occurs, the sending server becomes unavailable for subsequent tasks, while the receiving server remains available for handling new tasks."
After modifying the description, complete code can be written that passes all test cases
CSOAhelp长期稳定承接各大科技公司如TikTok、Google、Amazon等的OA笔试代写服务,确保满分通过。如有需求,请随时联系我们。
CSOAhelp 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.
选择题如果有available options可以加一下好么以后
谢谢