Notice
Recent Posts
Link
일 | 월 | 화 | 수 | 목 | 금 | 토 |
---|---|---|---|---|---|---|
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 |
Tags
- RxSwift
- Safari Inspector
- IOS
- Swift디자인패턴
- algorithm
- 클린코드
- RC
- ARC
- unittest
- TDD
- five lines of cdde
- alamofire
- hackerrank
- AutoLayout
- Di
- Swift코딩테스트
- 프로그래머스
- css학습
- firestore
- firebase
- 코딩테스트입문
- ios면접
- UIKit
- mrc
- 리팩터링
- SWIFT
- 카카오맵클론
- 앱의생명주기
- storekit2
- five lines of code
Archives
- Today
- Total
샘성의 iOS 개발 일지
[Warm Up] Staircase 본문
728x90
문제 설명:
Staircase detail
This is a staircase of size : n = 4
#
##
###
####
Its base and height are both equal to n. It 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.
내 풀이:
func staircase(n: Int) -> Void {
for i in 1...n {
// 띄어쓰기 먼저 반복 후, 마지막에 #가 출력되야 함
print(String(repeating: " ", count: n - i) + String(repeating: "#", count: i))
}
}
728x90
'Algorithm > HackerRank' 카테고리의 다른 글
[Implementation] Apple and Orange (0) | 2023.05.12 |
---|---|
[Implementation] Grading Students (0) | 2023.05.12 |
[Warm Up] Time Conversion (0) | 2023.05.11 |
[Warm Up] Birthday Cake Candles (0) | 2023.05.11 |
[Warm Up] Diagonal Difference (0) | 2023.05.11 |