Array Rotation

0

0 votes
Hard
Problem

Given an array of size n*n , rotate the array such that the outer layer rotates 90 degree in clockwise direction , next inner layer rotates 90 degree in anticlockwise direction , next inner layer in clockwise and so on.

sample input :

4

11 12 13 14

15 16 17 18

19 20 21 22

23 24 25 26

output :

23 19 15 11

24 17 21 12

25 16 20 13

26 22 18 14

 

Sample Input
4
11 12 13 14
15 16 17 18
19 20 21 22
23 24 25 26
Sample Output
23 19 15 11
24 17 21 12
25 16 20 13
26 22 18 14
Time Limit: 5
Memory Limit: 256
Source Limit:
Editor Image

?