Wrong Answer - Part of 1st Solution accepted by Judge

  • 0
    class Solution {
       vector<int> getRow(int rowIndex) {
        long temp , prev,i;
        vector<int> v;
            return v;
        prev = 1;
        for(int i=1;i<=rowIndex;i++){
            int t = (v[i-1] * (rowIndex-i+1))/(i);
        return v;
         Same Solution is used for generating each row in the Problem Pascals triangle I is accepted but this 
         is giving wrong answer for n = 30

  • 0

    Be careful about integer overflow. You need to convert the result of the multiplication to (long long). I noticed this when I saw the output it gave compared to mine. Index 15 or 16 is a negative number due to overflow.

Log in to reply

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