java neat solution with boolean array
```\n/\nMany solution comes with int array. I use boolean array to save memory and operation whlile comparing.\n/\nclass Solution {\n    public int sumOfBeautie
```\n/*\nMany solution comes with int array. I use boolean array to save memory and operation whlile comparing.\n*/\nclass Solution {\n    public int sumOfBeauties(int[] nums) {\n        int sum = 0;\n        int n = nums.length;\n        boolean[] r = new boolean [n];\n        \n        int maxl = nums[0], minr = nums[n - 1];\n            \n        for (int i = n - 2; i >= 0; i--)\n        {\n            if (nums[i] < minr) r[i] = true;\n            minr = Math.min(minr , nums[i]);\n        }\n       \n        \n        for (int i = 1; i < nums.length - 1; i++)\n        {\n            if (maxl < nums[i] && r[i])\n                sum += 2;\n            else if (nums[i - 1] < nums[i] && nums[i] < nums[i + 1])\n                sum += 1;\n            \n            maxl = Math.max(maxl, nums[i]);   \n        }\n        \n        return sum;\n    }\n}
[]