hi, let Avik connect you.


** You can give your thought about this content and request modifications if needed from Ask For Modifications page. Thank You.

** You can check all the posts on the Posts page.

** More about me in the About Me section.

Binary Pattern


  • Approach:

    1. For i = 0 to N.

      • For j = 0 to N-i times.

      • Print (i + 1)%2


  • Time and Space Complexity:

      • Time Complexity: O(N^2)

      • Space Complexity: O(1)


Code [C++]

#include <bits/stdc++.h>

void printPatt(int n) {

for(int i=0; i<n; i++){

for(int j=0; j<n-i; j++){

cout<<(i+1)%2;

}

cout<<endl;

}

}