Staircase – HackerRank Problem solution
Question:
Consider a staircase of size n=4:
#
##
###
####
Observe that its base and height are both equal to n , and the image is drawn using #
symbols and spaces. The last line is not preceded by any spaces.
Write a program that prints a staircase of size n
input:
6
Output:
#
##
###
####
#####
######
Here is actual problem HackerRank.
Answer:
Solution Logic
- Take variable which stores value of white space, initialize it with array size -1
- Iterate loop for number of rows and number
- Print white space in rows for white space the print #
- Reduce white space number by one