subject

Write a function: class Solution { public int solution (int) A); }
that, given a zero-indexed array A consisting of N integers representing the initial test scores of a row of students, returns an array of integers representing their final test scores in the same order).
There is a group of students sat next to each other in a row. Each day, students study together and take a test at the end of the day. Test scores for a given student can only change once per day as follows:
• If a student sits immediately between two students with better scores, that student's score will improve by 1 when they take the test.
• If a student sits between two students with worse scores, that student's test score will decrease by 1.
This process will repeat each day as long as at least one student keeps changing their score. Note that the first and last student in the row never change their scores as they never sit between two students.
Return an array representing the final test scores for each student once their scores fully stop changing. Test Ou
Example 1:
Input: (1,6,3,4,3,5]
Returns: (1,4,4,4,4,5]
On the first day, the second student's score will decrease, the third student's score will increase, the fourth student's score will decrease by 1 and the fifth student's score will increase by 1, i. e. (1,5,4,3,4,5). On the second day, the second student's score will decrease again and the fourth student's score will increase, i. e. (1,4,4,4,4,5). There will be no more changes in scores after that.

ansver
Answers: 2

Other questions on the subject: Computers and Technology

image
Computers and Technology, 23.06.2019 00:50, AmbitiousAndProud
Representa os dados de um banco de dados como uma coleç? o de tabelas constituídas por um conjunto de atributos, que definem as propriedades ou características relevantes da entidade que representam. marque a alternativa que representa o modelo descrito no enunciado. escolha uma:
Answers: 3
image
Computers and Technology, 23.06.2019 01:20, shiann2002
Me with this program in c++ ! computers represent color by combining sub-colors red, green, and blue (rgb). each sub-color's value can range from 0 to 255. thus (255, 0, 0) is bright red. (130, 0, 130) is a medium purple. (0, 0, 0) is black, (255, 255, 255) is white, and (40, 40, 40) is a dark gray. (130, 50, 130) is a faded purple, due to the (50, 50, 50) gray part. (in other word, equal amounts of red, green, blue yield gray).given values for red, green, and blue, remove the gray part. ex: if the input is 130 50 130, the output is: 80 0 80. thus, find the smallest value, and then subtract it from all three values, thus removing the gray.
Answers: 3
image
Computers and Technology, 23.06.2019 02:30, jalaholmes2027
Three out of five seniors remain undecided about a college major at the end of their senior year.
Answers: 3
image
Computers and Technology, 24.06.2019 02:30, journeyhile5
How to apply the fly in effect to objects on a slide
Answers: 1
You know the right answer?
Write a function: class Solution { public int solution (int) A); }
that, given a zero-indexe...

Questions in other subjects:

Konu
Mathematics, 16.03.2020 06:26
Konu
Mathematics, 16.03.2020 06:27
Konu
Mathematics, 16.03.2020 06:29
Konu
Mathematics, 16.03.2020 06:39