DEV Community

Discussion on: Challenge - Print Spiral

Collapse
 
evanoman profile image
Evan Oman

Should the space complexity be constant or linear? Probably O(1) since O(n) would allow you to build an array.

Collapse
 
heikodudzus profile image
Heiko Dudzus

I wanted to allow to build up one single line before printing. I think that would result in a space complexity of O(n). That allows to build an array, but not to build an array containing all entries of the spiral (being O( n2 )).