https://rakesh-trri.medium.com/rearrange-an-array-in-maximum-minimum-form-set-2-o-1-extra-space-9842a4cdc3e4