How will I calculate the time and space complexity for this pyramid algo?
There is one major for loop in this case 

for(m=0; m&lt;len; m++)


It has a complexity of O(len)
Inside this loop, there are 4 other loops, but they are additive in nature and not nested. Each of those loops has a length of &lt;=len. Thus the overall complexity of this program would be O(len*len)
The space complexity will be also be the same.