Very simple java solution using boolean array
Approach:\n All the numbers left to current should be less and all the numbers right to current should be high.\n So First we loop from left to right by maintai
**Approach**:\n* All the numbers left to current should be less and all the numbers right to current should be high.\n* So First we loop from left to right by maintaining the maxLeft and if current is greater than maxLeft then all nums to the left are less.\n* Similarly we loop from right to left by maintaining the minRight and if current is less than minRight then all nums to the right are high.  \n\n```\nclass Solution {\n    public int sumOfBeauties(int[] nums) {\n        boolean[] left = new boolean[nums.length];\n        boolean[] right = new boolean[nums.length];\n        \n        left[0] = true;\n        int leftMax = nums[0];\n        for(int i = 1; i < nums.length; i++) {\n            if(nums[i] > leftMax) {\n                left[i] = true;\n                leftMax = nums[i];\n            }\n        }\n        \n        right[nums.length-1] = true;\n        int rightMin = nums[nums.length-1];\n        for(int i = nums.length-2; i >= 0; i--) {\n            if(nums[i] < rightMin) {\n                right[i] = true;\n                rightMin = nums[i];\n            }\n        }\n        \n        int beautyCount = 0;\n        for(int i = 1; i < nums.length-1; i++) {\n            if(left[i] && right[i]) {\n                beautyCount += 2;\n            }\n            \n            else if(nums[i-1] < nums[i] && nums[i] < nums[i+1]) {\n                beautyCount += 1;\n            }\n            \n        }\n        return beautyCount;\n    }\n}\n```
['Java']