https://medium.com/@ricardo.andres.guerra.santana/efficiently-solving-the-array-manipulation-problem-986caef3ca8f