Description
Solutions
Submission
Pairs
🔥 FULLTIME

Consider two arrays of integers, a[n] and b[n]. What is the maximum number of pairs that can be formed where a[i] > b[j]? Each element can be in no more than one pair.

Find the maximum number of such possible pairs.

Function Description

Complete the function findNumOfPairs in the editor below.

findNumOfPairs has the following parameters:

  1. int a[n]: an array of integers
  2. int b[n]: an array of integers

Returns

int: the maximum number of pairs possible

Example 1:

Input:  a = [1, 2, 3], b = [1, 2, 1]
Output: 2
Explanation:
Two ways the maximum number of pairs can be selected:
  • {a[1], b[0]}={2, 1} and {a[2], b[2]}={3, 1} are valid pairs.
  • {a[1], b[0]}={2, 1} and {a[2], b[1]}={3, 2} are valid pairs.
  • No more than 2 pairs can be formed, so return 2.
    Constraints:
      Unknown for now
    Thumbnail 0
    Testcase

    Result
    Case 1

    input:

    output: