Python Accumulate Max and Min
\nclass Solution:\n    def sumOfBeauties(self, nums: List[int]) -> int:\n        nums1 = list(accumulate(nums, lambda x, y: max(x, y)))\n        nums2 = list(ac
```\nclass Solution:\n    def sumOfBeauties(self, nums: List[int]) -> int:\n        nums1 = list(accumulate(nums, lambda x, y: max(x, y)))\n        nums2 = list(accumulate(nums[::-1], lambda x, y: min(x, y)))[::-1]\n        cnt = 0\n        for i in range(1, len(nums) - 1):\n            if nums1[i - 1] < nums[i] < nums2[i + 1]:\n                cnt += 2\n            elif nums[i - 1] < nums[i] < nums[i + 1]:\n                cnt += 1\n        return cnt\n```\n
['Python3']