Simple Java 2 Sweep with Boolean array
\nclass Solution {\n    public int sumOfBeauties(int[] nums) {\n        int len = nums.length;\n        boolean satisfied[] = new boolean[len];\n        int lef
```\nclass Solution {\n    public int sumOfBeauties(int[] nums) {\n        int len = nums.length;\n        boolean satisfied[] = new boolean[len];\n        int leftmax = Integer.MIN_VALUE;\n        int rightmin = Integer.MAX_VALUE;\n        int ans = 0;\n        \n        for(int i=1;i<len-1;i++){\n            // 1. Check if current element is the max element while going right \n            leftmax = Math.max(leftmax, nums[i-1]);\n            if(nums[i]>leftmax)\n                satisfied[i]=true;\n        }\n        for(int i=len-2;i>0;i--){\n            // 2. Check if the current element is smallest while going left\n            rightmin = Math.min(rightmin, nums[i+1]);\n            // 3. Mark condition 1 (for 2 points) as satisfied iff satisfied[i] is true already\n            if(nums[i]<rightmin)\n                satisfied[i] = satisfied[i] && true;\n            else\n                satisfied[i] = false;\n            // 4. if condition 1 is satisfied add 2 points else if condition 2 is satisfied add 1 point\n                if(satisfied[i])\n                    ans+=2;\n                else if(nums[i-1]<nums[i] && nums[i]<nums[i+1])\n                    ans+=1;\n            \n        }\n        \n        return ans;\n    }\n}\n```
['Java']