leetcode413
Posted AsenYang
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了leetcode413相关的知识,希望对你有一定的参考价值。
public class Solution { public int NumberOfArithmeticSlices(int[] A) { int curr = 0, sum = 0; for (int i = 2; i < A.Length; i++) if (A[i] - A[i - 1] == A[i - 1] - A[i - 2]) { curr += 1; sum += curr; } else { curr = 0; } return sum; } }
https://leetcode.com/problems/arithmetic-slices/#/description
以上是关于leetcode413的主要内容,如果未能解决你的问题,请参考以下文章
[LeetCode]413 Arithmetic Slices
[leetcode-413-Arithmetic Slices]
413. Arithmetic Slices(LeetCode)
Leetcode413. Arithmetic Slices