Notice
Recent Posts
Recent Comments
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 | 31 |
Tags
- LeetCode
- algorithum
- 코딩 테스트
- 사당돈
- 6월 첼린지
- 른당사피
- algorithm
- map
- 발리인망원
- two sum
- 코테
- findDulicate
- tree
- invert Binary Tree
- two pointers
- Array
- 투포인터
- 알탕뚝배기
- Find the Duplicate Number
- 알고리즘
- string
- java
- 망원 밥집
- 코딩 테세트
- prefix sum
- 발리 음식
- linked list
- 해물감성포차
- Python
- 맛집
Archives
- Today
- Total
기록하는 공간
[leetcode/kotlin] 118. Pascal's Triangle 본문
class Solution {
fun generate(numRows: Int): List<List<Int>> {
val totalArr: MutableList<List<Int>> = mutableListOf()
var innerArr: MutableList<Int> = mutableListOf(1)
for (i in 0 until numRows) {
totalArr.add(innerArr)
val _innerArr: MutableList<Int> = mutableListOf()
_innerArr.add(1)
for (j in 0 until innerArr.size - 1) {
_innerArr.add(innerArr[j] + innerArr[j +1 ])
}
_innerArr.add(1)
innerArr = _innerArr
}
return totalArr
}
}
'알고리즘 > leetcode' 카테고리의 다른 글
[leetcode/kotlin] 283. Move Zeros (0) | 2020.10.13 |
---|---|
[leetcode/kotlin] 290.Word pattern (0) | 2020.09.08 |
[leetcode/kotlin] 35.Search Insert Position (0) | 2020.06.10 |
[leetcode/kotlin] 392.Is Subsequence (0) | 2020.06.09 |
[leetcode/kotlin] 344. Reverse String (0) | 2020.06.04 |
Comments