1ms O(k) Java solution that beats 87.70%


  • 0
    K
    public class Solution {
        public List<Integer> getRow(int rowIndex) {
            List<Integer> ans = new ArrayList();
            int len = rowIndex;
            ans.add(1);
            for(int i=1;i<=len;i++)
            {
                double num = ans.get(i-1) * ((double)(len - i + 1) / i);
                ans.add((int)(Math.round(num)));
            }
            return ans;
        }
    }

Log in to reply
 

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