119. Pascal's Triangle II Easy

@problem@discussion
#Array#Dynamic Programming



1/**
2 * [119] Pascal's Triangle II
3 *
4 * Given an integer rowIndex, return the rowIndex^th (0-indexed) row of the 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: rowIndex = 3
10 * Output: [1,3,3,1]
11 * Example 2:
12 * Input: rowIndex = 0
13 * Output: [1]
14 * Example 3:
15 * Input: rowIndex = 1
16 * Output: [1,1]
17 *  
18 * Constraints:
19 * 
20 * 	0 <= rowIndex <= 33
21 * 
22 *  
23 * Follow up: Could you optimize your algorithm to use only O(rowIndex) extra space?
24 * 
25 */
26pub struct Solution {}
27
28// problem: https://leetcode.com/problems/pascals-triangle-ii/
29// discuss: https://leetcode.com/problems/pascals-triangle-ii/discuss/?currentPage=1&orderBy=most_votes&query=
30
31// submission codes start here
32
33impl Solution {
34    pub fn get_row(row_index: i32) -> Vec<i32> {
35        vec![]
36    }
37}
38
39// submission codes end
40
41#[cfg(test)]
42mod tests {
43    use super::*;
44
45    #[test]
46    fn test_119() {
47    }
48}
49


Back
© 2025 bowen.ge All Rights Reserved.