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.
Patternify
Problem: Patternify
Problem Link: https://www.codingninjas.com/codestudio/problems/pattern_ify_893282
Companies Asked: Infosys
Approach:
Just printed the pattern as instructed on the question.
Time and Space Complexity:
Time Complexity: O(N*N)
Space Complexity: O(N*N)
Code [C++]
#include <bits/stdc++.h>
vector<string> printPatt(int n)
{
vector<string>answer;
for(int i=0; i<n; i++){
string ret = "";
for(int j=0; j<n-i; j++){
ret += '*';
}
// cout<<ret<<endl;
answer.push_back(ret);
}
return answer;
}