注册一亩三分地论坛,查看更多干货!
您需要 登录 才可以下载或查看附件。没有帐号?注册账号 
x
coding(70min) + work style (不限时,有推荐时间), 有demo link 可以提前多次练习熟悉hankrank的考试环境
1:Maximum System Memory Capacity
Given n servers where the memory capacity of the i-th server is represented by memory[i]. A system always contains an even number of servers. If the system has 2x servers, then x of them will be primary servers and the other x will be backup servers. For each primary server P, there exists a backup server B where memory >= memory[P]. The system's memory capacity is the sum of the memory capacities of all primary servers. Given n servers and an array memory, find the maximum system memory capacity that can be formed using the n servers.
. check 1point3acres for more.
x 个 primary server, x 个 backup server
总能在 backup servers 中找一个server j power[j] > 任意在一个primary servers 中的 i power[i]
..
思路: 排序(从小到大),两两组合 比如 abcdef (a, b), (c, d) (e, f) a, c, e 在primary, b, d, f 在backup
[b]2:Minimum Sum to Make Array Non-Decreasing
A set of n servers are used for horizontally scaling an application. The goal is to have the computational power of the servers in non-decreasing order. To do so, you can increase the computational power of each server in any contiguous segment by x. Choose the values of x such that after the computational powers are in non-decreasing order, the sum of the x values is minimum.
Example: n = 5, power = [3, 4, 1, 6, 2]. Add 3 units to subarray (2,4) and 4 units to subarray (4,4). Final arrangement: [3, 4, 4, 9, 9]. Answer is 3 + 4 = 7..1point3acres
思路: 找power中的所有下降处, 结果就是 所有下降处的|差值| 之和
走过路过求加米!加米不会扣除自己的大米,希望能攒点积分看帖,谢谢大家!祝大家都拿到心仪的Offer! |