CS-OA cs-vo Faang

Particle Media Inc OA – News Break OA – OA代写 – 面试代面 – 面试辅导 – 面试辅助

由中国“一点资讯”创始人郑朝晖在美国创立的新闻信息平台News Break近年来在美国颇受欢迎,近期也开启了对NG的招聘,我们一起来看看它的真题吧。

1. Maximum Common Companies

There are friends_nodes\text{friends\_nodes}friends_nodes friends, numbered from 1 to friends_nodes\text{friends\_nodes}friends_nodes, who buy wholesale products from different companies. There are friends_edges\text{friends\_edges}friends_edges pairs of friends where each pair of friends is connected by the common company they buy products from. Companies are numbered from 1 to 100. Note that if x[i]x[i]x[i] and y[i]y[i]y[i] are connected by a company c[i]c[i]c[i], then x[i]x[i]x[i] and y[i]y[i]y[i] are also connected by the company c[i]c[i]c[i], then x[i]x[i]x[i] and z[i]z[i]z[i] are also said to be connected by c[i]c[i]c[i]. Find the maximal product of x[i]x[i]x[i] and y[i]y[i]y[i] that share the largest group of friends which a common company connects.



Everyone uses the same company, but not everyone is connected. A graphical representation is:

The largest group is {1, 2, 3, 7}, and its largest elements are 3 and 7. Their product is 21.

2. Counting Analogous Arrays

A covert agent has some crucial information stored in the form of an array of integers. The array contains sensitive information and it must not be revealed to anyone. However, there are few things about the array which are known.

An array is said to be analogous to the secret array if all the following conditions are true:

  • The length of the array is equal to the length of the secret array.
  • Each integer in the array lies in the interval [lowerBound,upperBound][ \text{lowerBound}, \text{upperBound} ][lowerBound,upperBound].
  • The difference between each pair of consecutive integers of the array must be equal to the difference between the respective pair of consecutive integers in the secret array. In other words, let the secret array be [s[0],s[1],s[2],…,s[n−1]][s[0], s[1], s[2], \ldots, s[n-1]][s[0],s[1],s[2],…,s[n−1]] then the analogous array [a[0],a[1],a[2],…,a[n−1]][a[0], a[1], a[2], \ldots, a[n-1]][a[0],a[1],a[2],…,a[n−1]] must be equal to [s[0],s[1],s[2],…,s[n−1]][s[0], s[1], s[2], \ldots, s[n-1]][s[0],s[1],s[2],…,s[n−1]].

Given the value of the integers lowerBound\text{lowerBound}lowerBound and upperBound\text{upperBound}upperBound, inclusive, and the array of differences between each pair of consecutive integers of the secret array, find the number of arrays that are analogous to the secret array. If there is no array analogous to the secret array, return 0.

For example:

makefile复制代码consecutiveDifference = [-2, 1, -2, 5]
lowerBound = 3
upperBound = 10

The logic to create an analogous array starting from the lower bound is:

  • Start with a value of 3.
    • Subtract consecutiveDistances[0], 3 - (-2) = 5
    • Subtract consecutiveDistances[1], 5 - (-1) = 6
    • Subtract consecutiveDistances[2], 6 - (-2) = 8
    • Subtract consecutiveDistances[3], 8 - 5 = 3

Note that none of the values is out of bounds. All possible analogous arrays are:

  • [3, 5, 6, 8, 3]
  • [4, 6, 7, 9, 4]
  • [5, 7, 8, 10, 5]

The answer is 3.

Function Description

Complete the function countAnalogousArrays in the editor below.

countAnalogousArrays has the following parameters:

  • int consecutiveDifference[n]: the differences between each pair of consecutive integers in the secret array
  • int lowerBound: an integer
  • int upperBound: an integer


  • int: the number of arrays that are analogous to the secret array

如果您也有OA代写的需求,请联系我们,我们服务至上,立志做北美面试支持机构第一品牌。 CSOAHELP

Leave a Reply

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