C solution
\nint sumOfBeauties(int* nums, int numsSize){\n    int sum = 0;\n    int pre_max = nums[0];\n    int suf_min = nums[numsSize-1];\n    int* pre = (int*)malloc(si
```\nint sumOfBeauties(int* nums, int numsSize){\n    int sum = 0;\n    int pre_max = nums[0];\n    int suf_min = nums[numsSize-1];\n    int* pre = (int*)malloc(sizeof(int)*numsSize);\n    int* suf = (int*)malloc(sizeof(int)*numsSize);\n    for(int i = 0 ; i < numsSize; i++){\n       if(nums[i] > pre_max){\n            pre_max = nums[i];\n       }\n        pre[i] = pre_max;\n    }\n    for(int i = numsSize - 1 ; i >= 0 ; i--){\n        if(nums[i] < suf_min){\n            suf_min = nums[i];\n        }\n        suf[i] = suf_min;\n    }\n    for(int i = 1; i <= numsSize - 2; i++){\n        if(nums[i] > pre[i-1] && nums[i] < suf[i+1])sum+=2;\n        else if(nums[i] > nums[i-1] && nums[i+1] > nums[i])sum+=1;\n    }\n    return sum;\n}\n```
['C']