PracHub
QuestionsPremiumCoachesLearningGuidesInterview Prep

Quick Overview

This question evaluates combinatorics, array manipulation, and space-efficient algorithm design by requiring computation of a specific row of Pascal’s triangle without constructing the full triangle.

  • medium
  • Other
  • Coding & Algorithms
  • Software Engineer

Return the k-th row of Pascal-like triangle

Company: Other

Role: Software Engineer

Category: Coding & Algorithms

Difficulty: medium

Interview Round: Take-home Project

## Problem Given an integer `rowIndex` (0-indexed), return the `rowIndex`-th row of Pascal’s triangle. Pascal’s triangle is defined as: - Row 0 is `[1]` - Each subsequent row starts and ends with `1` - Each interior element is the sum of the two elements directly above it: - `row[i][j] = row[i-1][j-1] + row[i-1][j]` ### Input - `rowIndex`: integer (`>= 0`) ### Output - An array/list of length `rowIndex + 1` containing the values in that row. ### Constraints (memory-focused) - `0 <= rowIndex <= 10^5` - You should use **O(rowIndex)** extra space (a full 2D triangle may exceed memory limits). ### Example - `rowIndex = 4` → `[1, 4, 6, 4, 1]`

Quick Answer: This question evaluates combinatorics, array manipulation, and space-efficient algorithm design by requiring computation of a specific row of Pascal’s triangle without constructing the full triangle.

Return the 0-indexed rowIndex-th row of Pascal's triangle using O(rowIndex) space.

Constraints

  • rowIndex >= 0

Examples

Input: (0,)

Expected Output: [1]

Explanation: First row.

Input: (1,)

Expected Output: [1, 1]

Explanation: Second row.

Input: (4,)

Expected Output: [1, 4, 6, 4, 1]

Explanation: Example row.

Input: (6,)

Expected Output: [1, 6, 15, 20, 15, 6, 1]

Explanation: Larger row.

Hints

  1. Update a one-dimensional row from right to left.
Last updated: Jun 27, 2026

Loading coding console...

PracHub

Master your tech interviews with 8,000+ real questions from top companies.

Product

  • Questions
  • Learning Tracks
  • Interview Guides
  • Resources
  • Premium
  • For Universities
  • Student Access

Browse

  • By Company
  • By Role
  • By Category
  • Topic Hubs
  • SQL Questions
  • Compare Platforms
  • Discord Community

Support

  • support@prachub.com
  • (916) 541-4762

Legal

  • Privacy Policy
  • Terms of Service
  • About Us

© 2026 PracHub. All rights reserved.

Related Coding Questions

  • Implement a multi-button click detector - Other (hard)
  • Compute total after discounting most expensive item - Other (medium)
  • Implement multiplication without using the multiplication operator - Other (Medium)
  • Prove reservoir sampling correctness - Other (Medium)
  • Write mini-batch gradient descent - Other (Medium)