My simple java solution


  • 0
    X
    public class Solution {
        public List<Integer> getRow(int rowIndex) {
            List result=new ArrayList();
            if(rowIndex==0) result.add(1);
            else if(rowIndex==1) {result.add(1); result.add(1);}
            else{
                List preRow=getRow(rowIndex-1);
                result.add(1);
                for(int i=0;i<rowIndex-1;i++){
                    result.add((int)(preRow.get(i))+(int)(preRow.get(i+1)));
                }
                result.add(1);
            }
            return result;
        }
    }

Log in to reply
 

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