FastPrepGet Maximum Events
Problems/Get Maximum Events

Get Maximum Events

Amazon logoAmazon● HardFULLTIMEOA

Updated Sep 2026

QuestionFunctionExamplesConstraints

Problem statement

You are given an array payload of size n, where payload[i] represents the size of the (i)-th event payload. The task is to select a subset of events and rearrange them into a new array optimizedPayload that satisfies the following conditions:

  • The first segment is strictly increasing.
  • The second segment is strictly decreasing.
  • The third segment is strictly increasing.

The goal is to maximize the number of events included in optimizedPayload.

Function Specification:

Complete the function getMaximumEvents in the editor.

getMaximumEvents has the following parameter:

  1. int payload[n]: Array of payload sizes.

Output:

int: Maximum number of events that can be selected.

Function

getMaximumEvents(payload: int[]) → int

Examples

Example 1

payload = [1, 3, 5, 4, 2, 6, 8, 7, 9]return = 9

The subset optimizedPayload = [1, 3, 5, 4, 2, 6, 7, 8, 9] satisfies the increasing-decreasing-increasing sequence configuration.

Constraints

  • 2 ≤ n ≤ 2×10^5
  • 1 ≤ payload[i] ≤ 10^9
  • payload contains at least 2 distinct elements.

More Amazon interview questions

  • Lexicographically Largest IdentifierOA · Seen Nov 2026
  • Assign Escalations to TeamsONSITE INTERVIEW · Seen Nov 2026
  • Best Time to Buy and Sell StockONSITE INTERVIEW · Seen Nov 2026
  • Course SchedulePHONE SCREEN · ONSITE INTERVIEW · Seen Nov 2026
  • Maximize Shipment Order by Sorting One WindowOA · Seen Nov 2026
  • Maximum Earnings Across WarehousesONSITE INTERVIEW · Seen Nov 2026
  • Priority Message BufferONSITE INTERVIEW · Seen Nov 2026
  • Search in a Rotated Sorted ArrayPHONE SCREEN · ONSITE INTERVIEW · Seen Nov 2026
  • Top K Frequent ElementsOA · PHONE SCREEN · ONSITE INTERVIEW · Seen Nov 2026
  • Fill One Exact-Length Binary WindowOA · Seen Nov 2026

Similar questions at other companies

  • Minimum Satellite Data Transfer IterationsHSBC · OAHSBC interview questions
  • Minimum Cost to Select People for Skill QuotasVisa · OAVisa interview questions
  • Maximize Wall HitsOpenAI · OAOpenAI interview questions
  • Find Niceness 🌺Goldman Sachs · OAGoldman Sachs interview questions
  • Maximum Meetings from Start Times and DurationsMorgan Stanley · OAMorgan Stanley interview questions
  • Maximum Length Pair ChainInMobi · ONSITE INTERVIEWInMobi interview questions
  • Hard Disk Clustering CostConfluent · OAConfluent interview questions
  • Split Array to Minimize the Largest SumInfosys · OAInfosys interview questions
  • Split Array Largest SumAuxoAI · OA
  • Delete and Freeze GameRubrik · OARubrik interview questions

Interview reports that mention this question

  • Amazon Full-Time OA Problems, Recent Reports (Part 4 of 5)

Amazon interview experiences

  • Amazon Experienced SDE Onsite Questions: 1 Experience
  • Amazon SDE Onsite Interview Questions: 9 Experiences
  • Amazon SDE II and L5 FDE Interview Questions: 4 Experiences
  • Amazon Full-Time OA Problems, Earlier Reports (Part 5 of 5)
  • Amazon New Grad OA Problems: Every Task We Have (Part 3 of 5)
See Amazon hiring insights
Saved
class Solution {
    public int getMaximumEvents(int[] payload) {
      // write your code here
    }

}
Checking account…