Find Maximum Pairs
Learn this problemProblem statement
An AWS client wants to deploy multiple applications and needs two servers, one for their frontend and another for their backend. They have a list of integers representing the quality of servers in terms of availability. The client's preference is that the availability of an application's frontend server must be greater than that of its backend.
Two arrays of same size s, frontend[s] and backend[s] where elements represent the quality of servers, create pairs of elements (frontend[i], backend[i]) such that frontend[i] > backend[i] in each pair. Each element from an array can be picked only once to form a pair. Find the maximum number of pairs that can be formed.
Function
findMaximumPairs(frontend: int[], backend: int[]) → int
Complete the function findMaximumPairs in the editor.
findMaximumPairs has the following parameters:
int frontend[s]: frontend server qualitiesint backend[s]: backend server qualities
Returns
int: the maximum number of pairs that can be formed
Examples
Example 1
frontend = [1, 2, 3]backend = [1, 2, 1]return = 2Example 2
frontend = [1, 2, 3, 4, 5]backend = [6, 6, 1, 1, 1]return = 3Constraints
- 1 ≤ s ≤ 105
- 1 ≤ frontend[i], backend[i] ≤ 109
More Amazon problems
- Drone Delivery RouteOA · Seen Aug 2026
- Package Dependency OrderPHONE SCREEN · ONSITE INTERVIEW · Seen Aug 2026
- Unfulfilled Customers by Inventory PriorityOA · Seen Aug 2026
- Calculate Beauty ValuesOA · Seen Aug 2026
- Maximize Distance to the Closest Occupied SeatONSITE INTERVIEW · Seen Aug 2026
- Package Delivery SystemOA · Seen Aug 2026
- Select Least Resource TasksOA · Seen Aug 2026
- Maximum Length-K Window Sum over Sparse SegmentsOA · Seen Aug 2026