Dsa
Two Pointers
Easy
Maximize K Pairs
Given two arrays of integers, your task is to form k pairs by picking one element from each array so that the sum of these pairs is maximized. Print the maximum possible sum of pairs. A pair (A[i], B[j]) contributes A[i] + B[j] to the total sum.
Input Format:
- First line contains space-separated integers representing the first array.
- Second line contains space-separated integers representing the second array.
- The third line contains an integer k.
Output Format:
- A single integer representing the maximum sum of k pairs.
Example:
Input:
1 4 5 7
3 6 8 9
3
Output:
31
Key concepts
two_pointerssortinggreedy
Practise this out loud — free
Start a mock interview on THIS exact question — a voice AI interviewer opens with it, pushes back like a real onsite, then hands you an instant scorecard.
🎙 Practise this question now