My Java with array version


  • 0
    L

    '''
    public List<Integer> getRow(int rowIndex) {
    List<Integer> list = new LinkedList<>();

        int[] parray = new int[rowIndex + 1];
        parray[0] = 1;
        
        int count = 1;
        while (count <= rowIndex) {
            int i = count;
            while (i > 0) {
                parray[i] = parray[i] + parray[i - 1];
                i--;
            }
            count++;
        }
        
        for (int n : parray) {
            list.add(n);
        }
        
        return list;
    }
    

    '''


Log in to reply
 

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