very easy c++ sol || O(N) sol || using single array
int n=nums.size();\n        \n        vectorans(n,1);\n        \n        for(int i=1;inums[i-1] )\n            {\n                ans[i]=ans[i-1]+1;\n          
int n=nums.size();\n        \n        vector<int>ans(n,1);\n        \n        for(int i=1;i<n;i++)\n        {\n            if(nums[i]>nums[i-1] )\n            {\n                ans[i]=ans[i-1]+1;\n                \n            }\n        }\n        for(int i=n-2;i>=0;i--)\n        {\n            if(nums[i]>nums[i+1] and ans[i]<=ans[i+1])\n            {\n                ans[i]=ans[i+1]+1;\n            }\n        }\n        int sum=0;\n        for(auto itr:ans)\n        {\n            sum+=itr;\n        }\n        \n        return sum;
['Array', 'Greedy', 'C', 'C++']