Instructions
How Test Timing Works: Please make sure you can complete this test in one sitting, as the timer cannot be stopped once you begin. Clicking "Agree & Start" starts your running timer, even if you are not actively in the test. Importantly, the timer does not pause if you log out or get disconnected from the assessment.
Test duration: 45 mins
No. of questions: 2 questions
A Few Things to Consider:
- This is a programming test. Please be prepared to encounter programming/coding challenges during the assessment.
- You must submit a response to all questions to be considered completed.
- For an optimal experience, ensure you have a stable internet connection, and please complete this test in Mozilla Firefox 101+ or higher or Google Chrome 102+ or higher.
Question 1
HackerRank is organizing a hackathon for all its employees.
A hackathon is a team event, and there are n teams taking part. The number of employees in the i-th team is denoted by teamSize[i]
. In order to maintain uniformity, the team size of at most k teams can be reduced. Find the maximum number of teams of equal size that can be formed if team size is reduced optimally.
Example
There are n = 5 teams, and team sizes are teamSize = [1, 2, 2, 3, 4]
, and the maximum number of teams whose size can be reduced is k = 2.
The team size of the last 2 teams can be reduced to 2, thus teamSize = [1, 2, 2, 2, 2]
. The maximum number of teams with equal size is 4.
Function Description
Complete the function equalizeTeamSize
in the editor below.
equalizeTeamSize
has the following parameters:
int teamSize[n]
: the number of employees in each teamint k
: the maximum number of teams whose size can be reduced
Returns
int
: the maximum number of equal-size teams possible
Constraints
- 1 ≤ n ≤ 200,000
- 1 ≤
teamSize[i]
≤ 1,000,000,000 - 0 ≤ k ≤ 1,000,000,000
Sample Case 0
Sample Input For Custom Testing
STDIN FUNCTION
4 teamSize[] size n = 4
1 teamSize[] = [1, 2, 3, 4]
7
3
8
1 k = 1
Sample Output
2
Explanation
The number of employees in the second team can be reduced to 1. No more teams can be chosen since k = 1.
Question 2
A shipping company's control panel needs a query that returns a list of all customer packages that are in the process of being delivered.
The result should have the following columns:
- email: customer email address
- total_packages: total number of all packages for a specific customer
- total_weight: total weight of all packages for a specific customer
The result should be sorted in descending order by total_weight
.
Note:
- The total weight of all packages is equal to the sum of the weights of all packages.
- Only packages with the status 'created', 'shipped', or 'on hold' should be included in the result.
Schema:
customers | ||
---|---|---|
id | INT | PRIMARY KEY |
VARCHAR(255) | Customer email address |
packages | ||
---|---|---|
id | INT | PRIMARY KEY |
status | VARCHAR(20) | Status of the package |
weight | FLOAT | Weight of the package |
customers_packages | |
---|---|
customer_id | INT |
package_id | INT |
customers :
packages :
id | status | weight |
---|---|---|
1 | delivered | 93.37 |
2 | created | 86.16 |
3 | delivered | 66.24 |
4 | delivered | 78.63 |
5 | on hold | 53.33 |
6 | cancelled | 53.34 |
7 | created | 13.25 |
8 | delivered | 17.54 |
9 | shipped | 42.80 |
10 | on hold | 72.64 |
11 | cancelled | 93.14 |
12 | delivered | 64.94 |
13 | delivered | 58.34 |
14 | shipped | 6.92 |
15 | cancelled | 58.50 |
16 | delivered | 99.20 |
17 | delivered | 11.26 |
18 | created | 94.78 |
19 | shipped | 12.28 |
20 | created | 5.16 |
customers_packages :
customer_id | package_id |
---|---|
1 | 4 |
1 | 6 |
1 | 13 |
2 | 18 |
2 | 7 |
2 | 8 |
2 | 9 |
2 | 15 |
3 | 11 |
3 | 20 |
3 | 19 |
3 | 17 |
3 | 16 |
3 | 14 |
3 | 12 |
3 | 1 |
3 | 10 |
3 | 5 |
3 | 3 |
3 | 2 |
Expected Output Example:
total_packages | total_weight | |
---|---|---|
aflowerdew2@columbia.edu | 6 | 236.49 |
nbrashier1@reference.com | 3 | 150.83 |
我们长期稳定承接各大科技公司如TikTok、Google、Amazon等的OA笔试代写服务,确保满分通过。如有需求,请随时联系我们。
We consistently provide professional online assessment services for major tech companies like TikTok, Google, and Amazon, guaranteeing perfect scores. Feel free to contact us if you're interested.