Wonderbiz Tech | Onsite | Hard
Anonymous User
42

Given a positive odd integer n, create a n x n matrix filled with elements from 1 to n2 in the order shown in the image below.

Input: 3

image

Output:

9, 8, 7

2, 1, 6

3, 4, 5

Input: 11

Output:

121, 120, 119, 118, 117, 116, 115, 114, 113, 112, 111

82, 81, 80, 79, 78, 77, 76, 75, 74, 73, 110

83, 50, 49, 48, 47, 46, 45, 44, 43, 72, 109

84, 51, 26, 25, 24, 23, 22, 21, 42, 71, 108

85, 52, 27, 10, 9, 8, 7, 20, 41, 70, 107

86, 53, 28, 11, 2, 1, 6, 19, 40, 69, 106

87, 54, 29, 12, 3, 4, 5, 18, 39, 68, 105

88, 55, 30, 13, 14, 15, 16, 17, 38, 67, 104

89, 56, 31, 32, 33, 34, 35, 36, 37, 66, 103

90, 57, 58, 59, 60, 61, 62, 63, 64, 65, 102

91, 92, 93, 94, 95, 96, 97, 98, 99, 100, 101
Comments (0)