Codementor Events

Print a ladder for given integer N

Published Nov 04, 2020

For given input N, print below pattern.

E.g. N = 5. Output should be >

0
00
000
0000
00000

Screenshot from 2020-11-04 20-44-45.png

Timecomplexity for above solution is O(N^2).

Now, how do we solve this in O(N) time complexity?
It requires very simple thinking and can you post O(N) solution in the comment below?

Also add the comment if you cant figure it out.

Discover and read more posts from Hardik Avaiya
get started