Simple C++  O(n) Solution
Just find the max in left side of index and min of right side then compare with current index element\n```\n    int sumOfBeauties(vector& nums) {\n        int m
Just find the max in left side of index and min of right side then compare with current index element\n```\n    int sumOfBeauties(vector<int>& nums) {\n        int m=nums[0];\n        vector<int> mp(nums.size(),0);\n        for(int i=1;i<nums.size()-1;i++){\n            if(nums[i]>m){\n                mp[i]=1;\n                m=nums[i];\n            }\n        }\n        m=nums[nums.size()-1];\n        for(int i=nums.size()-2;i>0;i--){\n            if(nums[i]<m){\n                mp[i]+=1;\n                m=nums[i];\n            }\n        }\n        int ans=0;\n        for(int i=1;i<nums.size()-1;i++){\n            if(mp[i]==2)ans+=2;\n            else if(nums[i-1]<nums[i] && nums[i]<nums[i+1])ans+=1;\n        }\n        return ans;\n    }
['C', 'C++']