Class Solution
java.lang.Object
g2401_2500.s2410_maximum_matching_of_players_with_trainers.Solution
2410 - Maximum Matching of Players With Trainers.<p>Medium</p>
<p>You are given a <strong>0-indexed</strong> integer array <code>players</code>, where <code>players[i]</code> represents the <strong>ability</strong> of the <code>i<sup>th</sup></code> player. You are also given a <strong>0-indexed</strong> integer array <code>trainers</code>, where <code>trainers[j]</code> represents the <strong>training capacity</strong> of the <code>j<sup>th</sup></code> trainer.</p>
<p>The <code>i<sup>th</sup></code> player can <strong>match</strong> with the <code>j<sup>th</sup></code> trainer if the player’s ability is <strong>less than or equal to</strong> the trainer’s training capacity. Additionally, the <code>i<sup>th</sup></code> player can be matched with at most one trainer, and the <code>j<sup>th</sup></code> trainer can be matched with at most one player.</p>
<p>Return <em>the <strong>maximum</strong> number of matchings between</em> <code>players</code> <em>and</em> <code>trainers</code> <em>that satisfy these conditions.</em></p>
<p><strong>Example 1:</strong></p>
<p><strong>Input:</strong> players = [4,7,9], trainers = [8,2,5,8]</p>
<p><strong>Output:</strong> 2</p>
<p><strong>Explanation:</strong></p>
<p>One of the ways we can form two matchings is as follows:</p>
<ul>
<li>
<p>players[0] can be matched with trainers[0] since 4 <= 8.</p>
</li>
<li>
<p>players[1] can be matched with trainers[3] since 7 <= 8.</p>
</li>
</ul>
<p>It can be proven that 2 is the maximum number of matchings that can be formed.</p>
<p><strong>Example 2:</strong></p>
<p><strong>Input:</strong> players = [1,1,1], trainers = [10]</p>
<p><strong>Output:</strong> 1</p>
<p><strong>Explanation:</strong></p>
<p>The trainer can be matched with any of the 3 players.</p>
<p>Each player can only be matched with one trainer, so the maximum answer is 1.</p>
<p><strong>Constraints:</strong></p>
<ul>
<li><code>1 <= players.length, trainers.length <= 10<sup>5</sup></code></li>
<li><code>1 <= players[i], trainers[j] <= 10<sup>9</sup></code></li>
</ul>
-
Constructor Summary
Constructors -
Method Summary
-
Constructor Details
-
Solution
public Solution()
-
-
Method Details
-
matchPlayersAndTrainers
public int matchPlayersAndTrainers(int[] players, int[] trainers)
-