Easy C++ solution.
IntuitionApproachComplexity
Time complexity:

Space complexity:
Code
# Intuition
<!-- Describe your first thoughts on how to solve this problem. -->

# Approach
<!-- Describe your approach to solving the problem. -->

# Complexity
- Time complexity:
<!-- Add your time complexity here, e.g. $$O(n)$$ -->

- Space complexity:
<!-- Add your space complexity here, e.g. $$O(n)$$ -->

# Code
```cpp []
class Solution {
public:
    int sumOfBeauties(vector<int>& nums) {
        int n=nums.size();
        int sum=0;
        vector<int>maxi(n);
        vector<int>mini(n);
        maxi[0]=nums[0];
        for(int i=1;i<n;i++){
            maxi[i]=max(maxi[i-1],nums[i]);
        }
        mini[n-1]=nums[n-1];
        for(int i=n-2;i>=0;i--){
            mini[i]=min(mini[i+1],nums[i]);
        }
        for(int i=1;i<n-1;i++){   
            if(nums[i]>maxi[i-1] && nums[i]<mini[i+1]){
                sum+=2;
            }
            else if(nums[i]>nums[i-1] && nums[i]<nums[i+1]){
                sum+=1;
            }
        }
        return sum;
    }
};
```
['C++']