티스토리 뷰
Problem
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.
Solution
function staircase(n) {
for (let i = 1; i <= n; i++) {
console.log("#".repeat(i).padStart(n));
}
}
Result
#
##
###
####
#####
Reference
https://www.hackerrank.com/challenges/staircase/problem
Staircase | HackerRank
Print a right-aligned staircase with n steps.
www.hackerrank.com
'Algorithms' 카테고리의 다른 글
Birthday Cake Candles (0) | 2020.08.16 |
---|---|
Mini-Max Sum (0) | 2020.08.04 |
Plus Minus (0) | 2020.07.29 |
Diagonal Difference in JavaScript (0) | 2020.07.27 |
Calculate the Max minus Min Value in Array (0) | 2019.09.08 |
공지사항
최근에 올라온 글
최근에 달린 댓글
- Total
- Today
- Yesterday
링크
TAG
- repeat()
- HashMap
- substring()
- algorithm
- hackerrank solution
- hackerrank
- java
- code refactoring
- 프로그래머스
- C++
- string class in java
- HackerRank Algorithm
- math.max
- 프로그래머스 알고리즘
- javascript
- spring boot application
- easy javascript algorithm
- equals()
- Javascript Algorithm
- Object type casting
- rest parameter
- ... in Javascript
- 알고리즘
- 프로그래머스 알고리즘문제
- math.abs
- Collection Framework
- hackerrank javascript solution
- easy algorithm
- compareTo()
- hackerrank javascript
일 | 월 | 화 | 수 | 목 | 금 | 토 |
---|---|---|---|---|---|---|
1 | ||||||
2 | 3 | 4 | 5 | 6 | 7 | 8 |
9 | 10 | 11 | 12 | 13 | 14 | 15 |
16 | 17 | 18 | 19 | 20 | 21 | 22 |
23 | 24 | 25 | 26 | 27 | 28 |
글 보관함