118. Pascal's Triangle Easy

@problem@discussion
#Array#Dynamic Programming



1/**
2 * [118] Pascal's Triangle
3 *
4 * Given an integer numRows, return the first numRows of Pascal's triangle.
5 * In Pascal's triangle, each number is the sum of the two numbers directly above it as shown:
6 * <img alt="" src="https://upload.wikimedia.org/wikipedia/commons/0/0d/PascalTriangleAnimated2.gif" style="height:240px; width:260px" />
7 *  
8 * Example 1:
9 * Input: numRows = 5
10 * Output: [[1],[1,1],[1,2,1],[1,3,3,1],[1,4,6,4,1]]
11 * Example 2:
12 * Input: numRows = 1
13 * Output: [[1]]
14 *  
15 * Constraints:
16 * 
17 * 	1 <= numRows <= 30
18 * 
19 */
20pub struct Solution {}
21
22// problem: https://leetcode.com/problems/pascals-triangle/
23// discuss: https://leetcode.com/problems/pascals-triangle/discuss/?currentPage=1&orderBy=most_votes&query=
24
25// submission codes start here
26
27impl Solution {
28    pub fn generate(num_rows: i32) -> Vec<Vec<i32>> {
29        vec![]
30    }
31}
32
33// submission codes end
34
35#[cfg(test)]
36mod tests {
37    use super::*;
38
39    #[test]
40    fn test_118() {
41    }
42}
43


Back
© 2025 bowen.ge All Rights Reserved.