DevHireLab
TutorialsBootcamp
Problems
Code SimulatorAI InterviewSoonContact
DevHireLab
TutorialsBootcamp
Problems
Code SimulatorAI InterviewSoonContact
Back to Arena
easy
Array

Pascal's Triangle

**Problem Statement:** Given an integer `numRows`, return the first `numRows` of Pascal's triangle. In Pascal's triangle, each number is the sum of the two numbers directly above it. **Hint / Expected Approach:** Build row from previous row **Edge Cases to Consider:** - (1) numRows = 1 - (2) numRows = 2 - (3) Large numRows overflow check

Examples

Example 1
Input: 1
Output: [[1]]
Example 2
Input: 2
Output: [[1],[1,1]]
Example 3
Input: 3
Output: [[1],[1,1],[1,2,1]]

Constraints

  • ▪1 <= nums.length <= 10^4
  • ▪-10^9 <= nums[i] <= 10^9
  • ▪Time complexity should be O(n) or O(n log n)

Watch Out For Edge Cases

  • ▪numRows = 1
  • ▪numRows = 2
  • ▪Large numRows overflow check
Frequently Asked At
GoogleAmazonMicrosoftTCSInfosys