Skip to content

Commit e4260f9

Browse files
authored
Create Find Triangular Sum of an Array.java
1 parent 979fdd6 commit e4260f9

File tree

1 file changed

+12
-0
lines changed

1 file changed

+12
-0
lines changed
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
class Solution {
2+
public int triangularSum(int[] nums) {
3+
int n = nums.length;
4+
while (n > 1) {
5+
for (int i = 0; i + 1 < n; i++) {
6+
nums[i] = (nums[i] + nums[i + 1]) % 10;
7+
}
8+
n--;
9+
}
10+
return nums[0];
11+
}
12+
}

0 commit comments

Comments
 (0)