Simple Intuitive Solution || O(n*n)
\nint sumImbalanceNumbers(vector<int>& nums) {\n        int res=0,j=0,n=nums.size();\n        for(int i=0;i<n;i++){\n            set<int>st;\n            int cn
```\nint sumImbalanceNumbers(vector<int>& nums) {\n        int res=0,j=0,n=nums.size();\n        for(int i=0;i<n;i++){\n            set<int>st;\n            int cnt=0;\n            for(int j=i;j<n;j++){\n                if(!st.empty()){\n                    if(st.find(nums[j])!=st.end()){\n                        // res+=cnt;\n                    }\n                    else if(st.find(nums[j]+1)!=st.end() and st.find(nums[j]-1)!=st.end()){\n                        cnt--;\n                    }\n                    else if(!(st.find(nums[j]+1)!=st.end() or st.find(nums[j]-1)!=st.end())){\n                        cnt++;\n                    }\n                        res+=cnt;\n                }\n                st.insert(nums[j]);\n            }\n        }\n        return res;\n    }\n```
['Greedy', 'C', 'Ordered Set']