subject

You are given an array of arrays a. Your task is to group the arrays a[i] by their mean values, so that arrays with equal mean values are in the same group, and arrays with different mean values are in different groups. Each group should contain a set of indices (i, j, etc), such that the corresponding arrays (a[i], a[j], etc) all have the same mean. Return the set of groups as an array of arrays, where the indices within each group are sorted in ascending order, and the groups are sorted in ascending order of their minimum element.
Example
For
a = [[3, 3, 4, 2],
[4, 4],
[4, 0, 3, 3],
[2, 3],
[3, 3, 3]]
the output should be
meanGroups(a) = [[0, 4],
[1],
[2, 3]]
mean(a[0]) = (3 + 3 + 4 + 2) / 4 = 3;
mean(a[1]) = (4 + 4) / 2 = 4;
mean(a[2]) = (4 + 0 + 3 + 3) / 4 = 2.5;
mean(a[3]) = (2 + 3) / 2 = 2.5;
mean(a[4]) = (3 + 3 + 3) / 3 = 3.
There are three groups of means: those with mean 2.5, 3, and 4. And they form the following groups:
Arrays with indices 0and 4 form a group with mean 3;
Array with index 1 forms a group with mean 4;
Arrays with indices 2and 3 form a group with mean 2.5.
Note that neither
meanGroups(a) = [[0, 4],
[2, 3],
[1]]
nor
meanGroups(a) = [[0, 4],
[1],
[3, 2]]
will be considered as a correct
In the first case, the minimal element in the array at index 2 is 1, and it is less then the minimal element in the array at index 1, which is 2.
In the second case, the array at index 2 is not sorted in ascending order.
For
a = [[-5, 2, 3],
[0, 0],
[0],
[-100, 100]]
the output should be
meanGroups(a) = [[0, 1, 2, 3]]
The mean values of all of the arrays are 0, so all of them are in the same group.
Input/Output
[execution time limit] 3 seconds (java)
[input] array. array. integer a
An array of arrays of integers.
Guaranteed constraints:
1 ≤ a. length ≤ 100,
1 ≤ a[i].length ≤ 100,
-100 ≤ a[i][j] ≤ 100.
[output] array. array. integer
An array of arrays, representing the groups of indices

ansver
Answers: 1

Another question on Computers and Technology

question
Computers and Technology, 22.06.2019 10:40
Program using c++ only on visual studio pig is a simple two player dice game, played with one die. the first player to reach or surpass 50 is the winner. each player takes a turn rolling the dice. they add to the pot with each roll, having to decide to roll again and increase the pot, or cash out. the risk being they could lose the amount they’ve accumulated into the pot. the rules for each player’s die roll. 1. roll the dice. a. if user rolled a 1, i. the pot gets set to zero ii. the other player goes to step 1. b. a roll of 2-6 is added to the pot. 2. user can choose to hold or roll again. a. choice roll. return to step 1. b. choice hold. i. increment player score by the pot amount. ii. pot gets set to 0. iii. second player gets to roll and goes to step 1. program requirements: ● before each opponent begins ○ output the score for the person and the computer. ○ output the opponents whose turn is beginning and ask the user to hit enter to continue. ● with each dice roll. ○ output the die value, and amount of the round pot. ○ if it’s the users roll ask if they want to roll again ( r ) or hold ( h ). your program should allow r, r, h or h as valid input. if input is anything else, ask the user again until valid input is obtained. ○ the ai will continue playing until the round pot is 20 or more. ● once a player’s score is greater or equal to 50 then they have won, it will no longer ask if they want to keep rolling the die or not. ● once there is a winner ○ score totals are output along with who the winner was. user or computer ○ player is asked if they want to play again y or n. valid input should be y, y, or n, n. ● when a new game starts the starting roll goes to the player that did not roll last. if the user rolled last in the previous game, then the computer rolls first and vice versa. when the program first begins, the player will make the first roll of the first game. development notes : ● you will need a way to roll dice in your program. the rand() function works well, but returns an integer. if we want numbers 0 – 9 we can get the value modulus 10. ● call srand() with a value to seed it. it’s common to seed it with the current computer clock, include ctime, and then call srand(time(
Answers: 1
question
Computers and Technology, 22.06.2019 23:30
Define a function printfeetinchshort, with int parameters numfeet and numinches, that prints using ' and " shorthand. ex: printfeetinchshort(5, 8) prints: 5' 8"
Answers: 1
question
Computers and Technology, 23.06.2019 20:10
Leo is a recruitment executive for a large company. he has identified new labor resource requirements in both the marketing and production departments. what should be his first step in recruiting candidates for the positions? a. conduct background checks of candidates b. make job offers c. arrange interviews d. conduct reference checks e. place job ads on job sites
Answers: 1
question
Computers and Technology, 24.06.2019 07:00
Jean has kept the content of her website limited to what is important; she has also ensured that the text follows a particular style and color all throughout her website. which website features has jean kept in mind? jean has limited the content of her website to what is important; this ensures (clarity, simplicity, harmony and unity) of the content. she has also formatted the text in a particular style and color throughout her website, ensuring (balance, simplicity, consistency)
Answers: 2
You know the right answer?
You are given an array of arrays a. Your task is to group the arrays a[i] by their mean values, so t...
Questions
question
Social Studies, 21.11.2019 17:31
Questions on the website: 13722359