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
Problem: Binary Pattern
Problem Link: www.codingninjas.com/codestudio/problems/binary-pattern_893335
Companies Asked: Cognizant
Approach:
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++]
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;
}
}