reverse array iterative inplace