728x90
Problem
Approach
Just simple pyramid making problem.
Fill the gap with new array and add '#'.
Code
function staircase(n) {
for(let i = 1; i <= n; i++) {
let line = new Array(n-i).fill(' ').join('')
line += new Array(i).fill('#').join('')
console.log(line)
}
}
728x90
'Research > Coding Test' 카테고리의 다른 글
HackerRank_Grading Students (0) | 2023.04.05 |
---|---|
HackerRank_Birthday Cake Candles (0) | 2023.04.05 |
HackerRank_Plus Minus (0) | 2023.04.02 |
HackerRank_Diagonal Difference (0) | 2023.03.30 |
leetcode_66. plus-one (0) | 2023.03.24 |
댓글