You are given a 0-indexed array nums of digits (0 to 9). Repeatedly replace nums with a new array one element shorter, where newNums[i] = (nums[i] + nums[i + 1]) % 10, until one element remains. Return that element, the triangular sum of nums.
You are given a 0-indexed array nums of digits (0 to 9). Repeatedly replace nums with a new array one element shorter, where newNums[i] = (nums[i] + nums[i + 1]) % 10, until one element remains. Return that element, the triangular sum of nums.
Example 1:
Input: {"nums":[1,2,3,4,5]}
Output: 8
Constraints:
1≤nums.length≤1000
0≤nums[i]≤9
Test Cases
Input (Stdin)
Expected Output (Stdout)
Execution Result
Run code to see results.
Input
arr ={"nums":[1,2,3,4,5]}
Row 0 is the input, 5 digits. Each new row is one shorter: every cell is (left parent + right parent) % 10.