https://leetcode.com/problems/pascals-triangle Easy

Решение

class Solution {
    fun generate(numRows: Int): List<List<Int>> {
        val res = ArrayList<List<Int>>(numRows)
        var i = 0
        while (i < numRows) {
            val row = ArrayList<Int>(i + 1)
            var v = 1L
            var j = 0
            while (j <= i) {
                row.add(v.toInt())
                v = v * (i - j) / (j + 1)
                j++
            }
            res.add(row)
            i++
        }
        return res
    }
}