Practice Real Company Assessment Patterns • Latest 2025–2026 Mock Tests

Programming Exercises

Write a function to generate the nth row of Pascal’s Triangle.

Hard

Problem 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)}") }
Log in or sign up to run or submit your code.Log inSign up
Input
A hardcoded value, e.g., n = 5.
Expected Output
Pascal's Triangle row 5: [1, 4, 6, 4, 1]