Document Summary

Given an integer a, generate a square matrix filled with elements from 1 to a2 in spiral order. The first and the only argument contains an integer, a. Return a 2-d matrix of size a x a satisfying the spiral order. Note: you only need to implement the given function. Do not read input, instead use the arguments to the function. Do not print the output, instead return values as specified. Codes for more details. vector > solution::generatematrix(int n) { // do not read input, instead use the arguments to the function. // do not print the output, instead return values as specified. # a[t][l:r + 1] for col in range(l, r + 1): result[t][col] = lastn lastn += 1 t += 1 elif direction is direction. south: # a[r][t:b + 1] for row in range(t, b + 1): result[row][r] = lastn lastn += 1 r -= 1 elif direction is direction. west:

Get access

Grade+
$40 USD/m
Billed monthly
Grade+
Homework Help
Study Guides
Textbook Solutions
Class Notes
Textbook Notes
Booster Class
10 Verified Answers

Related Documents