2221. Find Triangular Sum of an Array

Updated: 2024-03-12
1 min read
[]

On This Page

LeetCode problem 2221

class Solution:
    def triangularSum(self, nums: List[int]) -> int:
        n = len(nums)
        for i in range(n, 0, -1):
            for j in range(i - 1):
                nums[j] = (nums[j] + nums[j + 1]) % 10
        return nums[0]