484. Triangular Sum
Given a 0-indexed integer array nums, where each element nums[i] is a digit between 0 and 9 (inclusive), find the triangular sum of nums. The triangular sum is the value of the only element present in nums after the following process terminates: If nums has only one element, the process ends. Otherwise, create a new array newNums of length n - 1, where each element newNums[i] is calculated as (nums[i] + nums[i+1]) % 10. Replace nums with newNums and repeat the process until nums has only one element. Finally, print the triangular sum of nums.
The first line contains a single integer N, the length of the array. The next line contains N space-separated integers, representing the elements of the array.
An integer representing the triangular sum.
5 1 2 3 4 5
1 <= N <= 10^3