C++ || unordered_set || clean code || fast (3ms)
Solution 1: hash set (3ms)\n\nWe insert the sum of two adjacent values of nums into a hash set, and if inserted is false the value is already in the hash set, i
### Solution 1: hash set (3ms)\n\nWe insert the sum of two adjacent values of ```nums``` into a hash set, and if ```inserted``` is false the value is already in the hash set, i.e. we have seen it before. Doing this instead of ```unordered_set::count()``` and ```unordered_set::insert()``` avoids one hash set lookup and is faster.\n\n```\n    bool findSubarrays(vector<int>& nums) {\n        unordered_set<int> seen;\n        for (int i = 1; i < size(nums); ++i) {\n            const int sum = nums[i - 1] + nums[i];\n            auto [it, inserted] = seen.insert(sum);\n            if (!inserted) return true;\n        }\n        return false;\n    }\n```\n\n**Complexity Analysis**\n\n  * Time Complexity: O(n), we scan the input once.\n  * Space Complexity: O(n), we insert at most n - 1 different sums into the hashmap.\n\n\n### Appendix: speed up IO\n\nTo speed up IO I always have a header like this in my solutions:\n\n\n```\n// https://leetcode.com/problems/find-subarrays-with-equal-sum/\n// problem: 2395\nstatic int fast_io = []() { std::ios::sync_with_stdio(false); cin.tie(nullptr); cout.tie(nullptr); return 0; }();\n```\n\n_As always: Feedback is welcome and upvote if you like this post._
['C']