cresta OA 真题 之 Daily Stock Prices & Microorganisms Simulation – OA 代写 – 面试辅助 – VO help – 一亩三分地

题目 1:Daily Stock Prices

Objective

In this problem, you'll be given a list of daily stock prices, and you'll be asked to return the three stocks with the highest average price.

Implementation

Implement the function:

get_top_stocks(stocks, prices)

which takes as input:

  • a list of strings stocks, representing the considered stocks.
  • a list of 2 dimensions prices, representing the stock prices:
    • inner lists represent the prices of each stock for one day;
    • the outer list represents all days.

An example input would look like this:

["AMZN", "CACC", "EQIX", "GOOG", "ORLY", "ULTA"]
[
  [12.81, 11.09, 12.11, 10.93, 9.83, 8.14],
  [10.34, 10.56, 10.14, 12.17, ...]
]

Your get_top_stocks function should return a list containing the names of the three stocks with the highest average value.

The list should be sorted by decreasing average price.


题目 2:Microorganisms Simulation

Objective

Several microorganisms of different families have been arranged next to each other.

Knowing that a microorganism eats its neighbor if it is of a different family and smaller in size, write a program that returns the largest family and its size when the situation reaches an equilibrium.

Process

  • Each microorganism belongs to a family, defined by a letter, and has a size, defined by an integer.
  • At each simulation round, a microorganism can eat a neighbor, directly to the left or to the right, if the neighbor:
    • is from another family;
    • has a strictly smaller size.
  • If there is a valid target on both sides, the left one is chosen.
  • During a round, the resolution is done from left to right.
  • For example, if a microorganism can be eaten by both its left and right neighbors, the left one is chosen.
  • When a microorganism eats another, its size increases by the size of its target, and the place occupied by the target disappears.
  • In the same simulation round, a microorganism cannot both eat and be eaten.
  • The choice of event, eating or being eaten, is determined by the order of resolution.
  • The simulation ends when no more microorganisms can eat others.

At the end of the simulation, take the microorganism with the largest size, and return a string consisting of:

family size

That is, its family, a separation space, and its size.

The tests are designed so that at the end of the simulation there is always only one microorganism with the maximum size.

The maximum number of microorganisms given as input is 20.

Function

solve(families, sizes)

Parameters:

families: List[str]
sizes: List[int]

Return:

str

A string containing the name of the biggest bacterial family in the final situation, followed by a space and its size.


题目 3:Alchemy Atom Transformation

Objective

You have discovered ancient alchemical processes for transmuting matter.

You can add or remove protons and neutrons from an atom.

Your atom is placed in the game area. The x-axis represents the number of protons and the y-axis represents the number of neutrons.

You need to list the actions to be taken so that the atom reaches the expected number of protons and neutrons.

Available Actions

The following 3 predefined actions are available:

PROTON

Adds a proton to the atom.

In the game area, this is equivalent to moving it one square to the right.

NEUTRON

Adds a neutron.

This moves the atom down one square.

ALPHA

Removes two protons and two neutrons by alpha decay.

This moves the atom two squares diagonally left and up.

Return Value

You must return a list of strings corresponding to the actions to be performed.

For example, if you return a list containing the words:

["ALPHA", "PROTON", "PROTON", "PROTON"]

the atom will:

  1. lose two protons and two neutrons;
  2. regain 3 protons;
  3. finally move two squares up and one square to the right.

The order of the actions is not important.

There's no need to minimize the number of actions.

You are allowed to move your atom out of the grid, even through the upper and left borders.

Implementation

Implement the function:

solve(protons_start, neutrons_start, protons_target, neutrons_target)

This function must return a list of strings: the successive actions to be performed to go from the supplied atom to the target atom.

The function takes 4 input parameters:

  • protons_start and neutrons_start represent the number of protons and neutrons in the initial atom.
  • protons_target and neutrons_target represent the number of protons and neutrons in the desired atom.

如果你正在准备 Airbnb、Google、TikTok、OpenAI 等公司的技术面试,CSOAHelp 可以提供真实面试题解析和面试陪练支持。

我们也有代面试,面试辅助,OA代写等服务助您早日上岸~

Leave a Reply

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