C++ | Easy to Understand | Short and concise | Sets 🚀🎉
\nclass Solution {\npublic:\n    int sumImbalanceNumbers(vector<int>& nums) {\n        const int n = nums.size();\n        int result = 0;\n        for (int i =
```\nclass Solution {\npublic:\n    int sumImbalanceNumbers(vector<int>& nums) {\n        const int n = nums.size();\n        int result = 0;\n        for (int i = 0; i < n; ++i) {\n            unordered_set<int> uniqueNums;\n            int imbalanceCount = -1;\n            for (int j = i; j < n; ++j) {\n                if (uniqueNums.insert(nums[j]).second) {\n                    ++imbalanceCount;\n                    imbalanceCount -= uniqueNums.count(nums[j] + 1) + uniqueNums.count(nums[j] - 1);\n                }\n                result += imbalanceCount;\n            }\n        }\n        return result;\n    }\n};\n\n```
['C', 'Ordered Set']