Sparse Arrays Hackerrank Solution Python