// @lc code=start class Solution { public: int numberOfArithmeticSlices(vector<int>& nums) { int n = nums.size(); vector<unordered_map<long long, int>> f(n); int res = 0; for (int i = 1; i < n; ++i) { for (int j = 0; j < i; ++j) { long long k = 1LL * nums[i] - nums[j]; auto it = f[j].find(k); int cnt = it == f[j].end() ? 0 : it->second; res += cnt; f[i][k] += cnt + 1; } } return res; } }; // @lc code=end