Marks :10
: 3 | : 1
One day the manager at a fintech company decides to create a team for the next project. There are a total of n employees and the skill-level of $$$i_{th}$$$ employee is $$$A[i]$$$.
He thinks that the more employees a project has, the easier it gets to work and the project would be finished in fewer days. So he decides to create a team with the maximum number of employees possible. But there must be a balance factor within the team, so the manager decides to create a team in such a way that the skill-level of each pair of employees within the team would differ by no more than 5.
Your task is to help the manager find the maximum number of employees that could be accommodated in the team.
The first line contains a single integer $$$1\le N \le 10^{5}$$$.
The second line contains $$$N$$$ space-separated integers , where $$$1\le i_{th} \le N$$$ integer denotes $$$1 \le A[i] \le 10^{9}$$$.
Output a single integer denoting the maximum employees that could be accomodated in the team.
8 4 17 8 24 6 10 12 9
4
6 1 10 17 12 15 2
3
In first test case we can chose employees with skills $$$4,8,6,9$$$ .
You need to login to view your submissions.
You need to login to view all submissions.
Result : Executed
Feel something is wrong with the test cases?
Result : Accepted
Test Cases :
But to Run or Submit the Problem, you need to Log In.
Continue to Log InYour challenge has been submitted successfully.
You will get a response soon via WhatsApp or Email.
Do let us know your issue.