C# O(n)
Intuition\n Describe your first thoughts on how to solve this problem. \n\n# Approach\n Describe your approach to solving the problem. \n\n# Complexity\n- Time 
# Intuition\n<!-- Describe your first thoughts on how to solve this problem. -->\n\n# Approach\n<!-- Describe your approach to solving the problem. -->\n\n# Complexity\n- Time complexity:\n<!-- Add your time complexity here, e.g. $$O(n)$$ -->\n\n- Space complexity:\n<!-- Add your space complexity here, e.g. $$O(n)$$ -->\n\n# Code\n```\npublic class Solution {\n    public int SumOfBeauties(int[] nums) \n    {\n        //   keep max from left    \n        //   min from right \n        var maxFromLeft = nums[0];\n\n        var n = nums.Length;\n        var minFromRight = new int[n];\n        minFromRight[n-1] = nums[n-1];\n        for(int i = n-2; i >= 0; --i)\n        {\n            minFromRight[i] = Math.Min(minFromRight[i+1], nums[i]);\n        }\n\n        var result = 0;\n\n        for(int i = 1; i <= nums.Length - 2; ++i)\n        {\n            if(nums[i-1] < nums[i] && nums[i] < nums[i+1])\n            {\n                ++result;\n\n                if(maxFromLeft < nums[i] && nums[i] < minFromRight[i+1])\n                {\n                    ++result;\n                }\n            }\n            \n            maxFromLeft = Math.Max(maxFromLeft, nums[i]);\n        }\n\n        return result;\n    }\n}\n```
['C#']