[Meesho] OA 2025 start – 14 Apr (remote prep + codesignal)

An investor has saved some money and wants to invest in the stock market. There are a number of stocks to choose from, and they want to buy at most 1 share in any company. The total invested cannot exceed the funds available. A friend who is a stock market expert has predicted the values of each stock after 1 year. Determine the maximum profit that can be earned at the end of the year assuming the predictions come true.

Example

saving = 250
currentValue = [175, 133, 109, 210, 97]
futureValue = [200, 125, 128, 228, 133]

To maximize profits, the investor should buy stocks at indices 2 and 4 for an investment of 109 + 97 = 206.
At the end of the year the stocks are sold for 128 + 133 = 261, so total profit is 261 - 206 = 55.

Function Description

Complete the function selectStock in the editor below. The function should return an integer that denotes the maximum profit after one year.

selectStock has the following parameter(s):

  • int saving: amount available for investment
  • int currentValue[n]: the current stock values
  • int futureValue[n]: the values of the stocks after one year

我们长期稳定承接各大科技公司如TikTok、Google、Amazon等的OA笔试代写服务,确保满分通过。如有需求,请随时联系我们。

We consistently provide professional online assessment services for major tech companies like TikTok, Google, and Amazon, guaranteeing perfect scores. Feel free to contact us if you're interested.

Leave a Reply

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