reversed array using as little memory as possible