leetcode(리트코드)118-Pascal's Triangle
 leetcode(리트코드)118-Pascal's Triangle 
 leetcode 118 - Pascal’s Triangle 문제입니다.
1. 문제
https://leetcode.com/problems/pascals-triangle/
2. Input , Output
1
2
Input: numRows = 5
Output: [[1],[1,1],[1,2,1],[1,3,3,1],[1,4,6,4,1]]
3. 분류 및 난이도
Eazy 난이도 문제입니다.
 Top 100 Interview 문제입니다.
4. 문제 해석
- 들어온 numRows값의 row를 가진 파스칼 삼각형을 구현합니다.
 
5. code
c++
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
class Solution {
public:
    vector<vector<int>> generate(int numRows) {
        vector<vector<int>> result;
        for(int i =0;i<numRows;++i)
        {
            vector<int> jvec;
            jvec.push_back(1);
            for(int j =1;j<i;++j)
            {
                jvec.push_back(result[i-1][j-1] + result[i-1][j]);
            }
            if(i!=0)
                jvec.push_back(1);
            result.push_back(jvec);
        }
        
        return result;
    }
};
6. 결과 및 후기, 개선점
코드에 대한 설명이 필요하신 분은 댓글을 달아주세요.!!
 This post is licensed under  CC BY 4.0  by the author.