leetcode LCP 2. 分式化简 思路

问题原链接 https://leetcode-cn.com/problems/deep-dark-fraction/

python3 解题代码:

class Solution:

    def fraction(self, cont: List[int]) -> List[int]:

        up = 1

        down = 0

        for i in range(len(cont)-1,-1,-1):

            temp = up

            up = cont[i] * up + down

            down = temp

        return [up, down]

解题思路

你可能感兴趣的:(leetcode LCP 2. 分式化简 思路)