題目:原題連結(困難)
标簽:數組
解法 | 時間複雜度 | 空間複雜度 | 執行用時 |
Ans 1 (Python) | 128ms (83.54%) | ||
Ans 2 (Python) | |||
class Solution:
def minNumberOperations(self, target: List[int]) -> int:
ans = 0
now = 0
for num in target:
if num > now:
ans += (num - now)
now = num
else:
now = num
return