Find a permutation P = [P_1, P_2, \ldots, P_N] of the integers \{1, 2, \ldots, N\} such that sum of averages of all consecutive triplets is minimized, i.e.
Since P_1 and P_n is not repeated and P_{n-1} and P_2 is repeated twice so it makes sense to assign maximum values to P_1 and P_n, followed by the next largest values to P_{n-1} and P_2. Rest of the values we can assign randomly since rest all of them are in multiples of 3. Thus we can have one of the possible permutations as follows:
don’t understand this question properly.
“such that sum of averages of all consecutive triplets is minimized, i.e.”. Even if we consider 1, 2 ,3,4
in all the cases the sum of averages would be (1 + 2 + 3 + 2 + 3 + 4) / 3. So can’t we just print [ 1 2 3 4] here?
As if we change the numbers the sum would always be same even if we do [3 2 4 1] right?
in this question if you think about it the sum of all the total consecutive sequences but it asks us about a specific permutation in which they all individually would also be minimum with respect to all the other cases of the permutations