Write a function 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 who sit next to each other in a row. Each day, the 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:
This process will repeat each day as long as at least one student's score changes. 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.
You can assume that: