Just BOMBED a Hacker Rank question for a work application and I m so upset,因为我感觉到,我喜欢一些事情,但可以指出:
Write a function that when given an expected_load of requests to servers, and an array of servers in which all indeces are powers of 2 ([1, 1, 2, 4, 8, etc.]), return the minimum number of servers required to equal the expected_load of requests. If there is no combination which would equal the expected_load exactly, return a -1.
我 sure诚地相信,我把问题的实际话说得bot,但这样会:
function(10, [1, 2, 4, 8, 16]) {
some stuff
}
收益2(在此情况下,需要服务器数量为3.1和服务器[3])
i m 假设你需要一个服务器数目的计算,但我无法说明如何将服务器作为你所加一切的总和加以追踪。 我开始:
getMinServers(expected_load, server_array){
for (let i = 0; i <= server_array.length, i++){
for (let j = i+ 1; j <= server_array.length; j++ {
if (server[i] + server[j] === expected_load){
**this is where my brain craps out**
}
}
}
}
我需要找到一种办法,来计算其评价联盟与预期负荷相加的阵列中的欠款数目......这样,你需要追踪目前拖欠款项的数额,以及所使用的/必要和我才智不会奏效的缺减额。