1299. Replace Elements with Greatest Element on Right Side

Обновлено: 2024-03-12
1 мин
[]

Содержание

LeetCode problem 1299

class Solution:
    def replaceElements(self, arr: List[int]) -> List[int]:
        m = -1
        for i in range(len(arr) - 1, -1, -1):
            t = arr[i]
            arr[i] = m
            m = max(m, t)
        return arr