Why this code give the wrong answer


  • 0
    J
    vector<int> getRow(int rowIndex) {
        vector<int> tmp;
        for(int i=0;i<=rowIndex;i++){
            if(i==0) tmp.push_back(1);
            else tmp.push_back(tmp[i-1]*(rowIndex-i+1)/i);
        }
        return tmp;
    }

Log in to reply
 

Looks like your connection to LeetCode Discuss was lost, please wait while we try to reconnect.