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
- Secure Maximum DeliveriesOA · Seen Jul 2026
- Find Median from Data StreamONSITE INTERVIEW · Seen Jul 2026
- Handwritten SigmoidPHONE SCREEN · Seen Jul 2026
- Handwritten SoftmaxPHONE SCREEN · Seen Jul 2026
- Koko Eating BananasONSITE INTERVIEW · Seen Jul 2026
- Loyal Customers Across Two DaysONSITE INTERVIEW · Seen Jul 2026
- Maximum System Memory CapacityOA · Seen Jul 2026
- Package Delivery SystemOA · Seen Jul 2026