given algorithm
Solved via multiple arrays