Here is my solution!


  • 0
    L
    public class Solution {
    public ArrayList<Integer> getRow(int rowIndex) {
        //csdn : http://blog.csdn.net/ljphhj
        ArrayList<Integer> list = new ArrayList<Integer>();
        for (int i=0; i<=rowIndex; ++i){
            list.add(1);
        }
        for(int i=0; i<=rowIndex; ++i){
            for (int j=i/2; j>=0; --j){
                if (j != 0 && j != i){
                    int left = list.get(j-1);
                    int right = list.get(j);
                    list.set(j, left+right);
                    list.set(i-j, left+right);
                }
            }
        }
        return list;
    }
    

    }


Log in to reply
 

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