follow the method of problem 'spiral matrix'