Simple Python Code || Hard Made Easy || O(N.N) ✅✅
Complexity\n- Time complexity:O(n^2)\n Add your time complexity here, e.g. O(n) \n\n\n# Code\n\nclass Solution:\n    def sumImbalanceNumbers(self, nums: List[in
# Complexity\n- Time complexity:$$O(n^2)$$\n<!-- Add your time complexity here, e.g. $$O(n)$$ -->\n\n\n# Code\n```\nclass Solution:\n    def sumImbalanceNumbers(self, nums: List[int]) -> int:\n        n=len(nums); res=0\n        for i in range(n):\n            j=i; imbalance=0; _set=set()\n            while j<n:\n                if nums[j] not in _set and nums[j]-1 in _set and nums[j]+1 in _set:\n                    imbalance-=1\n                if j-i>0 and nums[j] not in _set and nums[j]-1 not in _set and nums[j]+1 not in _set:\n                    imbalance+=1\n                _set.add(nums[j])\n                res+=imbalance\n                j+=1\n        return res\n```
['Python3']