Skip to content

Commit cf26bc2

Browse files
authored
Create Maximum Matching of Players With Trainers.java
1 parent bf4b647 commit cf26bc2

File tree

1 file changed

+15
-0
lines changed

1 file changed

+15
-0
lines changed
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
class Solution {
2+
public int matchPlayersAndTrainers(int[] players, int[] trainers) {
3+
Arrays.sort(players);
4+
Arrays.sort(trainers);
5+
int playerIdx = 0;
6+
int trainerIdx = 0;
7+
while (playerIdx < players.length && trainerIdx < trainers.length) {
8+
if (players[playerIdx] <= trainers[trainerIdx]) {
9+
playerIdx++;
10+
}
11+
trainerIdx++;
12+
}
13+
return playerIdx;
14+
}
15+
}

0 commit comments

Comments
 (0)