26. Print Pattern
Last updated
Last updated
The problem can be found at the following link: Question Link
To make this pattern, I followed a recursive technique with backtracking.
I kept reducing N by 5 in a loop until it got to 0 or less.
While doing this, I added the current N value to the output vector twice. Once before making the recursive call and once after.
The pattern comes from the sequence of values added to the vector.
Time Complexity: O(N)
, where N
is the input integer.
Auxiliary Space Complexity: O(N)
, as we store the pattern in a vector.
For discussions, questions, or doubts related to this solution, please visit our discussion section. We welcome your input and aim to foster a collaborative learning environment.
If you find this solution helpful, consider supporting us by giving a ⭐ star to the getlost01/gfg-potd repository.