We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
int numberOfArithmeticSlices(vector<int>& nums) { int n = nums.size(); if (n < 3) return 0; vector<int> dp(n, 0); for (int i = 2; i < n; ++i) { if (nums[i] - nums[i-1] == nums[i-1] - nums[i-2]) { dp[i] = dp[i-1] + 1; } } return accumulate(dp.begin(), dp.end(), 0); }
参考解法最后一行只适用于整个数组都是等差数列的情况,但不适用于:
[1,2,3,5,4,5,6]
这种情况。
The text was updated successfully, but these errors were encountered:
您再跑一下?您给的test case我测了一下是过的。
Sorry, something went wrong.
No branches or pull requests
参考解法最后一行只适用于整个数组都是等差数列的情况,但不适用于:
这种情况。
The text was updated successfully, but these errors were encountered: