注册一亩三分地论坛,查看更多干货!
您需要 登录 才可以下载或查看附件。没有帐号?注册账号
x
2 OA coding question
Code Question 1
Amazon stores its data on different servers at different locations. From time to time, due to several factors, Amazon needs to move its data from one location to another. This challenge involves keeping track of the locations of Amazon's data and reporting them at the end of the year.
At the start of the year, Amazon's data was located at n different locations. Over the course of the year, Amazon's data was moved from one server to another m times. Precisely, in the iᵗʰ operation, the data was moved from movedFrom[i] to movedTo[i].
Find the locations of the data after all m moving operations. Return the locations in ascending order.
Note:
It is guaranteed that for any movement of data:
There is data at movedFrom[i].
There is no data at movedTo[i].
Example
locations = [1, 7, 6, 8]
movedFrom = [1, 7, 2]
movedTo = [2, 9, 5]
Explanation
Data begins at locations listed in locations. Over the course of the year, the data was moved three times. Data was first moved from movedFrom[0] to movedTo[0], from 1 to 2. Next, data was moved from 7 to 9, and finally, from location 2 to 5.
In the end, the locations where data is present are [5, 6, 8, 9] in ascending order.
Function Description
Complete the function getFinalLocations in the editor below.
The function is expected to return an INTEGER_ARRAY.
The function accepts the following parameters:
INTEGER_ARRAY locations
INTEGER_ARRAY movedFrom
INTEGER_ARRAY movedTo
Code Question 2
You are in the Amazon's Cloud Infrastructure Team, and you are working on a project to optimize how data flows through its network of storage servers.
You are given with n storage servers, and the throughput capacity of each server is given in an integer array named throughput.
There are pipelineCount data pipelines that need to be connected to two 您好! 本帖隐藏的内容需要积分高于 188 才可浏览 您当前积分为 0。 使用VIP即刻解锁阅读权限或查看其他获取积分的方式 游客,您好! 本帖隐藏的内容需要积分高于 188 才可浏览 您当前积分为 0。 VIP即刻解锁阅读权限 或 查看其他获取积分的方式 tal transferRate, the data pipelines can optimally choose the pairs
[3, 3], [1, 3], [3, 1], [1, 1]
to obtain the maximum sum of
transferRate = (5 + 5) + (5 + 4) + (4 + 5) + (4 + 4) = 36.
Function Description
Complete the function maxTransferRate in the editor below.
maxTransferRate has the following parameters:
int throughput[n]: array of throughput provided by each server instance.
int pipelineCount: the number of data pipelines that need to be connected.
Returns
long: the maximum total transfer rate.
求大米,謝謝😊 |