CS-OA cs-vo Faang

Welcome to The Amazon Coding challenge – Amazon Web Services OA – 亚马逊笔试真题-Amazon 笔试真题


Amazon Web Services (AWS) has several processors for executing processes scheduled on its servers.

In order to maintain logical independence, a process is divided into segments. Each segment has two characteristics: the segment size (1 < segment size < 10^9), and a pointer to the next segment so
that the sequential order of execution is maintained within a process. Hence, this structure can be visualized as a linked list.

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


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

There are n = 5 segments with their segment sizes [2, 5, 4, 4, 5].

The longest non-increasing sub-list has 3 nodes:

Segment Size Segment Size Segment Size



If you're afraid that you can't solve the OA on your own, please scan the code to contact me or telegram

Leave a Reply

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