Array ( [0] => [1] => questions [2] => Basic [3] => Right-Triangle-with-Alphabets )
Print the pattern as shown below for all test cases.
First line contains the value N.
Print the output as shown in below examples.
3
A B B C C C
4
A B B C C C D D D D
5
A B B C C C D D D D E E E E E
Login to see Discussion
Step-i) assign 65 to ch as 65 is the ascii value of A
Step-ii) assign 1 to i
Step-iii) assign 1 to j
Step-iv)print ch and space and increment value of j by one
Step-v)repeat step iv till j is less than or equal to i
Step-vi)increment ch by one value , go to next line and increment i by one value
Step-vii) repeat steps iii to vi till i is less than or equal to N
Time Complexity: O(n^2)
Space Complexity: O(1)
Note :
Let us know if you can come up with a better approach, mail us at support@theinquisitive.in Your approach will be reviewed and posted with credits to you.
Login to see Solution