Easy to understand solution for beginners
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
```java []
class Solution {
    public int sumOfBeauties(int[] nums) {
               int[] arr1=new int[nums.length];
        int[] arr2=new int[nums.length];
        arr1[0]=nums[0];
        arr2[nums.length-1]=nums[nums.length-1];
        for(int i=1;i<nums.length;i++){
            int gt= nums[i];
            if(gt>arr1[i-1]){
                arr1[i]=gt;
            }else{
                arr1[i]=arr1[i-1];
            }
            if(i==0){
                continue;
            }else{
            int gt2=nums[nums.length-1-i];
            if(gt2>arr2[nums.length-1-i+1]){
                arr2[nums.length-1-i]=arr2[nums.length-1-i+1]; 
            }else{
                 arr2[nums.length-1-i]=gt2;  
            } 
            } 
        }
        int max=0;
        for(int i=1;i<nums.length-1;i++){
            int gt;
            if(nums[i-1]<nums[i] && nums[i]<nums[i+1]){
                if(arr1[i-1]<nums[i] && arr2[i+1]>nums[i]){
                   gt=2;
                }else{
                    gt=1;
                }
            }else{
                gt=0;
            }
            
            max+=gt;
        } 
        return max;
    }
}
```
['Java']