def optimalDivision(self, nums):
:type nums: List[int]
A = map(str, nums)
if len(A) <= 2:
return A + '/(' + '/'.join(A[1:]) + ')'
To get the largest result, the numerator has to be as large as possible, while the denominator has to be as small as possible. I just can't think of a case where A[1:] get's any smaller with a different division order instead of the default "one by one" order.