Build a component that generates a Pascal’s Triangle for a given hardcoded number of rows.
HardProblem Statement
Build a component that generates a Pascal’s Triangle for a given hardcoded number of rows.
Sample Input
5 (Number of rows)
Sample Output
Pascal's Triangle: [[1], [1, 1], [1, 2, 1], [1, 3, 3, 1], [1, 4, 6, 4, 1]]
Limits
Time: 2s · Memory: 256 MB
Code Editor
00:00
import React from "react";
const PascalsTriangle = () => {
return (
<div>
{/* Display Pascal's Triangle */}
</div>
);
};
export default PascalsTriangle;
Input
5 (Number of rows)
Expected Output
Pascal's Triangle: [[1], [1, 1], [1, 2, 1], [1, 3, 3, 1], [1, 4, 6, 4, 1]]