recursive solution for placing ships, without cloning the array