LeetCode LCP 2. Fraction Simplification

An overlay from the last turn

 1 class Solution(object):
 2     def fraction(self, cont):
 3         """
 4         :type cont: List[int]
 5         :rtype: List[int]
 6         """
 7         ans = [1,0]
 8         for i in range(len(cont)-1,-1, -1):
 9             temp = ans[0]
10             ans[0] = cont[i]*ans[0] + ans[1]
11             ans[1] = temp
12         return ans

 

Guess you like

Origin www.cnblogs.com/19990219073x/p/11716001.html