CS-OA cs-vo Faang

Amazon OA – Welcome toThe Amazon CodingChallenge – Maximizing Negative Months While Maintaining Positive Cumulative Profit and Loss – Longest Non-Increasing Sub-list in a Linked List

Amazon OA 近期火热发放中,我们一起来看看真题吧。

Maximizing Negative Months While Maintaining Positive Cumulative Profit and Loss

You are analyzing the market trends of Amazon stocks. An AWS financial service model returned an array of integers, PnL (Profit and Loss), for your portfolio representing that in the ith month, you will either gain or lose PnL[i]. All reported PnL values are positive, representing gains.

As part of the analysis, you will perform the following operation on the PnL array any number of times:

  • Choose any month i (0 ≤ i < n) and multiply PnL[i] by -1

Find the maximum number of months you can afford to face a loss, i.e., have a negative PnL, such that the cumulative PnL for each of the n months remains strictly positive i.e., remains greater than 0.

Note: The cumulative PnL for the ith month is defined as the sum of PnL from the starting month up to the ith month. For example, the cumulative PnL for the PnL = [3, -2, 5, -6, 1] is [3, 1, 6, 0, 1].

Example: Consider, n=4, and PnL = [5, 3, 1, 2]

Some of the possible arrays after performing the given operation some number of times:

Longest Non-Increasing Sub-list in a Linked List

Problem Statement: Amazon Web Services (AWS) utilizes several processors for executing processes scheduled on its servers. To maintain logical independence, a process is divided into segments. Each segment has two characteristics:

  1. The segment size (1 ≤ segment size ≤ 10^6).
  2. A pointer to the next segment, ensuring that the sequential order of execution is maintained within a process. This structure can be visualized as a linked list.

Objective: Given the segment structure of a process as a linked list, find the longest sub-list where the segment sizes are in non-increasing order. A sub-list of length 1 is always considered valid. If there are multiple sub-lists of maximum length, return the sub-list which occurs earliest.

Notes:

  1. A sub-list is obtained by removing some nodes from the head and some nodes from the tail of the linked list.
  2. Solve the problem using constant extra space.

我们提供OA代做服务,请注意,如果你是在OA的过程中搜索到本文,那么不幸的是我们将无法为您服务。得益于我们优质的服务和有竞争力的价格,我们的OA代做服务必须要预约才能够实行。我们的OA代做是一项收费服务,如果是希望免费获得答案的人不要联系我们

We provide OA agency services. Please note that if you search for this article during the OA process, unfortunately, we will not be able to serve you. Thanks to our high-quality service and competitive pricing, our OA outsourcing service requires an appointment to be implemented. Our OA agency is a paid service. If you want to get answers for free, please do not contact us.

联系我,查看题目全文。OA代做,代面试,面试代面,面试辅助。联系我 我们公开透明报价,做华人社区面试suport第一品牌。

Leave a Reply

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