100%
Intuition\n\n Describe your first thoughts on how to solve this problem. \n\n# Approach\n Describe your approach to solving the problem. \n\n# Complexity\n- Tim
# Intuition\n![Screenshot (581).png](https://assets.leetcode.com/users/images/8409f3d6-6b7e-4b78-b42e-9c6079c8bb81_1688312890.7393162.png)\n<!-- Describe your first thoughts on how to solve this problem. -->\n\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:\n    def sumImbalanceNumbers(self, nums: List[int]) -> int:\n        \n        ans = 0\n        \n        for i,start in enumerate(nums):\n            d = {}\n            d[start] = 1\n            cnt = 0\n            \n            for j in range(i+1, len(nums)):\n                n = nums[j]\n                if n in d:\n                    pass\n                else:\n                    if n+1 in d and n-1 in d:\n                        cnt -= 1\n                    elif n+1 not in d and n-1 not in d:\n                        cnt += 1\n                d[n] = 1\n                ans += cnt\n        \n        return ans\n```
['Python3']