Implement the function min_piles_needed(n, strengths) in a file called /app/solution.py. This function determines the minimum number of piles required such that all players are able to adequately participate given their strengths.
Functionality
You are required to implement the min_piles_needed function that takes two parameters:
n (an integer): represents the number of players.
strengths (a list of integers): contains the strengths of the players, where each strength is a non-negative integer.
The function should calculate and return the minimum number of piles needed so that players can participate, ensuring that no player in a pile has a strength less than the corresponding strength in other piles.
Input/Output Requirements
Input:
The function should accept two parameters:
An integer n, where ( 1 \leq n \leq 10^5 ).
A list strengths of length n, where each element is an integer ( 0 \leq \text{strength} \leq 10^9 ).
Output:
The function should return a single integer, which is the minimum number of piles needed.
Example
python
# Example input
min_piles_needed(5, [4, 1, 2, 3, 5])
# Example output
2
Constraints
Ensure that the solution is efficient and operates within reasonable time limits, ideally ( O(n \log n) ) or better, since the number of players can be large.
Implement this functionality as described and ensure that the code is organized and well-documented.