Solve spiral matrix ii problem similarly as spiral matrix.