Advertisement
2221. Find Triangular Sum of an Array
MediumView on LeetCode
2221.cs
C#
public class Solution
{
public int TriangularSum(int[] nums)
{
for (int currentLength = nums.Length - 1; currentLength > 0; currentLength--)
{
for (int index = 0; index < currentLength; index++)
nums[index] = (nums[index] + nums[index + 1]) % 10;
}
return nums[0];
}
}Advertisement
Was this solution helpful?