you give 0indexed array num distinct integer you want rearrange element array element rearrange array equal average neighborsMore formally rearrange array property range 1 numslength 1 numsi1 numsi1 2 equal numsireturn rearrangement num meet requirement Example 1input num 12345output 12453explanationwhen i1 numsi 2 average neighbor 14 2 25when i2 numsi 4 average neighbor 25 2 35when i3 numsi 5 average neighbor 43 2 35example 2input num 62097output 97620explanationwhen i1 numsi 7 average neighbor 96 2 75when i2 numsi 6 average neighbor 72 2 45when i3 numsi 2 average neighbor 60 2 3 constraints3 numslength 1050 numsi 105