Adobe OA真题 揭晓

  1. Question 1
    Starting with an empty set of integers named elements, perform the following query operations!
    The command push xinserts the value of xinto elements.
    The command pop x removes the value of xfrom elements.
    The integers in elements need to be ordered in such a way that after each operation is performed, the product of themaximum and minimum values in the set can be easily calculated.
    Function Description
    Complete the function maxMin in the editor below.
    maxMin has the following parameter(s):
    string operations[n]: an array of operations stringsint x[n]: an array of x where xlil goes with operations[il.
    Returns:
    intIn): an array of long integers that denote the product of the maximum and minimum of elements after each query
    Constraints
    1<n<105
    1<xi]<109
    lt is guaranteed that each operations[ijis either push or poplt is guaranteed that any value popped will exist in the array
  1. Question 2
    Given the three integers, x, y, and z, convert xto yby repeatedly performing these operations: adding 1 to xorsubtracting 1 from x. A maximum of z operations can be performed to reach y, and, if necessary, all operations may bethe same. As the operations are applied, keep track of the maximum value that x achieves. The goal is to create thehighest possible value of x somewhere along the way while arriving at the target value within z operations.
    Example
    X=4
    y=4
    z=4
    The maximum achievable value of is 6. Because a maximum of 4 moves are available, 1 can be added twice andsubtracted twice to arrive back at 4. Performing 0or 2 moves would still arrive at the target value but would havemaxima of 4 and 5, respectively.
    Function Description
    Complete the function findMaxNum in the editor below
    findMaxNum has the following parameter(s):
    int x: the starting value
    int y: the target value
    int z: the maximum number of steps
    Returns:
    int the maximum integer which can be made from xwhile converting xto yin at most steps; if x cannot be convertedto yafter at most z steps, return -1
    Constraints
    1<XYZ<108

Adobe这次的真题非常的简单,75分钟绰绰有余,基本只花半个小时就可以完成。

接到OA的小伙伴们不要犹豫,抓紧试一下。

Leave a Reply

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