Write a function to generate the nth row of Pascal’s Triangle.
HardProblem Statement
Write a function to generate the nth row of Pascal’s Triangle.
Sample Input
A hardcoded value, e.g., n = 5.
Sample Output
Pascal's Triangle row 5: [1, 4, 6, 4, 1]
Limits
Time: 2s · Memory: 256 MB
Code Editor
00:00
fun pascalRow(n: Int): List<Int> {
// Add your code here to generate the nth row
}
fun main() {
val n = 5
println("Pascal's Triangle row $n: ${pascalRow(n)}")
}
Input
A hardcoded value, e.g., n = 5.
Expected Output
Pascal's Triangle row 5: [1, 4, 6, 4, 1]