use one list from right to left override with java solution


  • 0
    R

    public List<Integer> getRow(int rowIndex) {
    List<Integer> result = new ArrayList<Integer>();
    if(rowIndex < 0) return result;
    //List<Integer> pre = new ArrayList<Integer>();
    //result.add(1);
    //pre = result;
    for(int i = 0; i <= rowIndex; i++) {
    result.add(1);
    for (int j = i-1; j > 0; j--) {
    result.set(j, result.get(j) + result.get(j-1));
    }
    }
    return result;
    }


Log in to reply
 

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