일 | 월 | 화 | 수 | 목 | 금 | 토 |
---|---|---|---|---|---|---|
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 | 29 | 30 | 31 |
Tags
- SQL
- 코드스테이츠
- 코딩공부
- array.slice()
- Hackerrank
- 역행자
- 코딩테스트
- 배열
- array.push()
- 개발자_조이킴
- 프로그래머스
- Algorithms
- JavaScript
- 개발자의 책장
- 코플릿
- join
- 정규표현식
- Programmers
- 블록체인
- Where
- array
- node.js
- 재귀함수
- 알고리즘
- Developer_JoyKim
- select
- for문
- 자바스크립트
- 최강의 인생
- MySQL
Archives
- Today
- Total
CodingSpace
[HackerRank/Algorithms] Warmup - Staircase 본문
Problem. Warmup - Staircase
Link.
https://www.hackerrank.com/challenges/staircase/problem?isFullScreen=true
Staircase | HackerRank
Print a right-aligned staircase with n steps.
www.hackerrank.com
Description.
Key Point.
My Answer.
'use strict';
process.stdin.resume();
process.stdin.setEncoding('utf-8');
let inputString = '';
let currentLine = 0;
process.stdin.on('data', function(inputStdin) {
inputString += inputStdin;
});
process.stdin.on('end', function() {
inputString = inputString.split('\n');
main();
});
function readLine() {
return inputString[currentLine++];
}
/*
* Complete the 'staircase' function below.
*
* The function accepts INTEGER n as parameter.
*/
function staircase(n) {
// Write your code here
let blank = ' '
let stair = '#'
for(let i = 1; i <= n; i++) {
console.log(blank.repeat(n - i) + stair.repeat(i));
}
}
function main() {
const n = parseInt(readLine().trim(), 10);
staircase(n);
}
References.
'HackerRank > Algorithm' 카테고리의 다른 글
[HackerRank/Algorithms] Implementation - Cut the sticks (0) | 2022.09.04 |
---|---|
[HackerRank/Algorithms] Warmup - Compare the Triplets (0) | 2022.09.03 |
[HackerRank/Algorithms] Implementation - Repeated String (0) | 2022.09.01 |
[HackerRank/Algorithms] Implementation - Cats and a Mouse (0) | 2022.08.30 |
[HackerRank/Algorithms] Implementation - Number Line Jumps (0) | 2022.08.29 |
Comments