AS II。446

1,lc官方题解暴力我都不懂。。

2,这尼玛也太难了。

3,没眼看不想看

日了

4,下次把思维模型写一下。

5,

#define LL long long
class Solution {
public:
    int numberOfArithmeticSlices(vector<int>& A) {
        int n = A.size();
        LL ans = 0;
        vector<map<LL, int>> cnt(n);
        for (int i = 1; i < n; i++) {
            for (int j = 0; j < i; j++) {
                LL delta = (LL)A[i] - (LL)A[j];
                int sum = 0;
                if (cnt[j].find(delta) != cnt[j].end()) {
                    sum = cnt[j][delta];
                }
                cnt[i][delta] += sum + 1;
                ans += sum;
            }
        }

        return (int)ans;
    }
};

5,题解还搞得能懂,代码就不行了。

原文地址:https://www.cnblogs.com/beiyueya/p/12791695.html