나는 이렇게 학습한다/Algorithm & SQL

0915. Beginner - Reduce but Grow

daco2020 2022. 9. 15. 21:07

Given a non-empty array of integers, return the result of multiplying the values together in order. Example:

[1, 2, 3, 4] => 1 * 2 * 3 * 4 = 24



Solution:

def grow(arr, i=1):
    return grow(arr, i*arr.pop()) if arr else i