CS-OA cs-vo Faang

Welcom to SE Graduate Program HackerRank Test 2024 – Booking.com

欧洲的booking开始大量发OA与面试了,下面我们来看看它的真题是什么。

1. Question 1

In a game, there is an array of cells, each with an integer value. In one move, merge any two cells to obtain a new cell that contains the sum of the two cells. The power needed in each move is the sum of the values of the two merged cells. The goal is to merge the cells until only one cell remains. Find the minimum possible power required to do so.

Example

cells = [20, 30, 40]

  1. Select cells with values 20 and 30 and merge them to obtain [50, 40]. The power needed for this move is 20+30=50
  2. Select cells with values 50 and 40 and merge them to obtain [90]. The power needed for this move is 50+40=90

The total power required is 50+90 = 140. This is the minimum possible power.

Function Description

Complete the function minPower in the editor.

minPower has the following parameter:

  • int cells[n]: the values of each cell

Returns

  • int: the minimum power required to finish the game

Constraints

  • 2 ≤ n ≤ 10^5
  • 1 ≤ cells[i] ≤ 100

Input Format For Custom Testing

[Custom Testing Input Format]

Sample Case 0

Sample Input For Custom Testing

STDINFUNCTION
3 ->cells[] size n = 3
30 ->cells[] = [30, 10, 20]
10
20

Sample Output

90

Explanation

  • Merge 10 and 20, power needed = 10+20 = 30, cells = [30,30].
  • Merge 30 and 30, power needed = 30+30 = 60, cells = [60].

The total power needed is 30+60 = 90.

2. Question 2

Given array = [6, 15, 2, 4, 3, 8, 19]. After applying heapify operation on the array, the array will look like:

Pick ONE option

  1. [19, 15, 6, 4, 3, 8, 2]
  2. [19, 6, 15, 4, 3, 8, 2]
  3. [19, 15, 4, 6, 3, 8, 2]
  4. [19, 6, 15, 8, 4, 3, 2]

3. Question 3

A warehouse manager must optimize the allocation of resources in their warehouse. There are two rows of storage units, having lengths n and m respectively. Each unit has a certain amount of resources, but some units (possibly, none) are currently empty. The empty units are denoted by 0. The manager wants to allocate new resources in these empty units such that the total number of resources in both rows is equal. Return the minimum equal total number of resources in each row, or -1 if such allocation is not possible.

For example, consider the two rows of storage units storageA = [1, 2, 0, 4] and storageB = [4, 5, 0, 0, 1]. Then, the minimum possible sum can be 12, obtained by making storageA = [1, 2, 5, 4] and storageB = [4, 5, 1, 1, 1].

Function Description

Complete the function minimumResources in the editor below.

minimumResources has the following parameters:

  • int storageA[n]: one row of integers
  • int storageB[m]: another row of integers

Returns

  • int: an integer, which, if positive, denotes the minimum equal total number of resources possible to obtain an equal sum, and if -1 indicates that it is not possible to obtain an equal sum.

Constraints

  • 1 ≤ n, m ≤ 10^5
  • 0 ≤ storageA[i], storageB[i] ≤ 10^4

Input Format For Custom Testing

The first line contains an integer n, which denotes the length of the array storageA. The next n lines contain the integers which belong to storageA. The next line contains the integer m, which denotes the length of the array storageB. The next m lines contain the integers which belong to storageB.

Sample Case 0

Sample Input For Custom Testing

STDINFUNCTION
5 ->storageA[] size n = 5
1storageA = [1, 0, 0, 5, 6]
0
0
5
6
5 ->storageB[] size m = 5
0storageB = [0, 8, 0, 9, 4]
8
0
9
4

Sample Output

23

Explanation

One possible solution is to fill the empty units in storageA with 4, 7 and storageB with 1, 1 respectively. This results in storageA' = [1, 4, 7, 5, 6] and storageB' = [1, 8, 1, 9, 4], each having a sum of 23.

4. Question 4

An articulation point, also known as a "separating vertex", is one whose removal increases the number of connected components in a graph. How many articulation points are in the graph shown?

Pick ONE option

  • 7
  • 2
  • 3
  • 4

我们还提供VO辅助,面试代面,如果有需要请联系我

If you need a complete question bank or assistance, please contact us.

有任何OA均可以联系我,100%AC,错一个不收钱。如果害怕自己解决不了OA,请扫码联系我 or telegram

If you're afraid that you can't solve the OA on your own, please scan the code to contact me or telegram

Leave a Reply

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