08 - Staircase | Warmup | Hackerrank Solution | Python

preview_player
Показать описание
⭐️ Content Description ⭐️
In this video, I have explained on how to solve staircase problem using simple string operation and rjust inbuilt function of python. This hackerrank problem is a part of Problem Solving | Practice | Algorithms | Warmup | Staircase and solved in python. The complexity of this solution is O (n).

Make a small donation to support the channel 🙏🙏🙏:-

#staircase #howtosolve #hackerrank #hackerranksolutions #hackersrealm #python #warmup #problemsolving #tutorial #algorithms #datastructures #programming #coding #codinginterview #education #aswin
Рекомендации по теме
Комментарии
Автор

#4
n=int(input('give the length of staircase'))
for i in range(1, n+1):
print((n-i)*' ' + i*'#')

vivekdubey
Автор

How can i know i have to initialise the var=0 before starting loop for them.
Please solve my query

shivam
Автор

for i in range(n):
x=" "*(n-1-i)
y="#"*(i+1)
print(x, y)
Output is correct but its showing error.

govindkeshari
Автор

can you tell me what's wrong with my code it prints exactlly the same but it says wrong answer
for i in range(n):
print(" "*(n-(i+1)), "#"*(i+1) )

gamescan
Автор

for i in range (1, n+1) can you explain this y we put n+1

madhumetha
Автор

skill up - use gen :P
```

def staircase(i):
while True:
res = "#" * i
yield str.rjust(res, n)


if __name__ == "__main__":
n = int(input().strip())
res = (next(staircase(i)) for i in range(1, n + 1))
print("\n".join(res))

```

marioamatucci
join shbcf.ru