C++ | Brute & Optimal Approaches ✅
C++: (Brute Approach)\n\nclass Solution {\npublic:\n\tbool findSubarrays(vector<int>& nums) {\n\t\tint n=nums.size();\n\t\tint count=0;\n\t\tfor(int i=0;i<n-1;i
**C++:** (**Brute Approach**)\n```\nclass Solution {\npublic:\n\tbool findSubarrays(vector<int>& nums) {\n\t\tint n=nums.size();\n\t\tint count=0;\n\t\tfor(int i=0;i<n-1;i++){\n\t\t\tfor(int j=i+1;j<n-1;j++){\n\t\t\t\tif(nums[j]+nums[j+1]==nums[i]+nums[i+1]) count++;\n\t\t\t}\n\t\t}\n\t\treturn count>=1;\n\t}\n};\n```\n****\n**Time Complexity:** **O(N^2)**\n**Space Complexity:** **O(N)**\n****\n**C++:** (**Hashmap Approach**)\n```\nclass Solution {\npublic:\n    bool findSubarrays(vector<int>& nums) {\n        int n = nums.size();\n        unordered_map<int,int> mp;\n        for(int i=1;i<n;i++){\n            int sum = nums[i]+nums[i-1];\n            mp[sum]++;\n            if(mp[sum]>1) return true;\n        }\n        return false;\n    }\n};\n```\n****\n**Time Complexity:** **O(N)**\n**Space Complexity:** **O(N)**\n****
['C']