CS-OA cs-vo Faang

[TikTok] AMS GradAssessment 2024 Start 23 Oct to 27 0ct (Generic) OA记录

照例写出送分选择题和SQL题

1. System Overhaul

A global research organization uses a multi-processor operating system to handle complex computational simulations. The system has been underperforming lately due to frequent context switching, irregular file retrieval times, and occasional race conditions between processes.

An evaluation revealed that the system uses a multilevel queue scheduling algorithm and an indexed sequential file organization method, and it lacks proper synchronization mechanisms. As the principal systems architect, which combination of strategies is most effective for resolving the existing issues and maintaining its multi-processor nature? 我认为选D,有不同意见的可以评论区留言。

2. Multicast Troubleshooting

A Unix-based distributed system runs a networking application using IGMP v3 for multicast data communication over a high port (above 1024). Pseudo-code for the multicast socket is shown.

During testing, some multicast messages are not received by all nodes in the multicast group. Network-related issues and firewall rules blocking IGMP traffic are ruled out. All nodes have IGMPv3 enabled. What could be the issue? 我认为选B,有不同意见的可以评论区留言。

3. SQL: Advertising System Referrers Report

An ad system report needs an update after changes were made to the backend. Previously, only the top-level domain was in the referrer field. The backend team decided to transfer the entire domain, including the subdomain.

Debug and modify the query below to reflect the backend changes. Replace the subdomain part with a wildcard (an asterisk) to get the report working again. 送分题,CONCAT('*.', SUBSTRING_INDEX(referrer, '.', -2))加一下就行

4. Optimal Server Purchase

You have to buy servers for the Tiktok platform to effectively manage their users, So you enter a shop to buy servers. Currently, the shop has n servers, where the price of the i^th server is represented by the array element price[i].

The shop has a special offer for its customers :

  • You can reduce the price of one server to the floor of half of its initial price.

The total cost of servers is calculated as the sum of the absolute differences in the price of all adjacent servers. Given n servers and an array price[i], find the minimum Total cost required to buy all the servers from the shop, it's your choice to accept and apply the offer to any one of the servers.

Example

Given n = 3, price = [1, 4, 1].

OperationpriceTotal Cost
1. Select the first server[0, 4, 1]
2. Select the second server[1, 2, 1]
3. Select the third server[1, 4, 0]

If you select the second server and reduce its price to half then the price will be changed into [1, 2, 1]. Then minimum Total cost to buy all of the three servers is equal to 1 - 2| + |2 - 1| = 2.

Function Description

Complete the function minimumTotalCost in the editor below. minimumTotalCost has the following parameter(s):

  • int price[n]: an array of integers representing the price of each server.

Returns

int: the minimum amount of money required to buy all the servers from the shop

Constraints

  • 2 ≤ n ≤ 10^5
  • 1 ≤ price[i] ≤ 10^4

Input Format For Custom Testing

Sample Case 0

5. Idle Servers

You have to effectively manage the servers of the TikTok platform. You are given 2^n servers, where the number of people using the i^th server is represented by the array data[i]. You can bring 2^n servers together, such that each server belongs to only one pair and set one to idle.

For each pair of servers, you can choose to set any server to idle, which means that a particular server will not work or is being stopped. Choosing a server to be idle or not comes with a cost which is calculated as follows:

  • If we choose the server which has the smaller data to be idle, then the cost incurred is equal to 1.
  • If we choose the server which has the larger data to be idle, then the cost incurred is equal to 0.

Now, the total working capacity of the servers is defined as the sum of data of the servers which are currently working or the servers which are not idle.

Given an integer n, an array data and an integer k, find the sum of the minimum cost of bringing 2^n servers together such that the total working capacity of the servers is greater than or equal to k. If it is impossible to achieve a total working capacity of servers greater or equal to k, print -1.

Example:

Given, n = 4, data = [3, 1, 5, 2], and k = 6. If we bring the servers [1, 5] and [3, 2] together and choose the server with the smaller data from the first pair to be idle and choose the server with the larger data from the second pair to be idle then the total working capacity of the servers is equal to 5 + 2 = 7, which is greater than k, and cost incurred is equal to 1. Hence, the minimum cost we can achieve is equal to 1, where the total working capacity of the servers is greater than or equal to k.

Function Description

Complete the function minimumCost in the editor below. minimumCost has the following parameter(s):

  • int data[2^n]: an array of integers denoting the number of people using that database.
  • int k: a non-negative integer

Constraints

  • 1 ≤ n ≤ 10^5
  • 1 ≤ data[i] ≤ 10^9
  • 1 ≤ k ≤ 10^15

OA代做,联系我, 包AC

Leave a Reply

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