Java Solution works just not for numbers too large.


  • 0
    K
        public List<Integer> getRow(int r) {
            List<Integer> list = new ArrayList<>();
            
            int n = 1;
            for(int i = 0; i <= r; i++){
                list.add(n);
                n =  n * (r-i) / (r+1);
            }
            return list;
        }
    }
    this is working however, when it gets to values that are too large to be handled as integers it fails.
    Any tips on how to make this work.

Log in to reply
 

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