brute force C++
Intuition\n Describe your first thoughts on how to solve this problem. \nlisting all the subarrays.\nas imbalance number has differnce larger than 1, which, we 
# Intuition\n<!-- Describe your first thoughts on how to solve this problem. -->\nlisting all the subarrays.\nas imbalance number has differnce larger than 1, which, we only need to check the + 1, and  -1, adj number, if there do not exsit these two number, means 1 imbalance.\n# Approach\n<!-- Describe your approach to solving the problem. -->\n\n# Complexity\n- Time complexity:\n<!-- Add your time complexity here, e.g. $$O(n)$$ -->\n\n- Space complexity:\n<!-- Add your space complexity here, e.g. $$O(n)$$ -->\n\n# Code\n```\nclass Solution {\npublic:\n    int sumImbalanceNumbers(vector<int>& nums) {\n        int res = 0;\n        for(int i = 0; i < nums.size(); i++){\n            vector<bool> vis(nums.size()*2, 0);\n            int cnt = 0;\n            vis[nums[i]] = 1;\n            for(int j = i + 1; j < nums.size(); j++){\n                if(!vis[nums[j]]){\n                    cnt += 1 - vis[nums[j] - 1] - vis[nums[j] + 1];\n                    vis[nums[j]] = 1;\n                }\n                res += cnt;\n            }\n        }\n        return res;\n    }\n};\n```
['C++']