🛒 C++ || YT LINK || EASY EXPLANATION 🛒
https://www.youtube.com/watch?v=PzBYQA6FshA\n\n\tc++ code\n\t\n\t\t\tclass Solution {\n\t\tpublic:\n\t\t\tint candy(vector& nums) {\n\t\t\tint n = nums.size();\
https://www.youtube.com/watch?v=PzBYQA6FshA\n\n\tc++ code\n\t\n\t\t\tclass Solution {\n\t\tpublic:\n\t\t\tint candy(vector<int>& nums) {\n\t\t\tint n = nums.size();\n\t\t\tvector<int> left(n, 1);\n\t\t\tvector<int> right(n, 1);\n\t\t\tfor(int i=1;i<n;i++)\n\t\t\t{\n\t\t\t\tif(nums[i]>nums[i-1])left[i]=left[i-1]+1;\n\t\t\t}\n\t\t\t for(int i=n-2;i>=0;i--)\n\t\t\t{\n\t\t\t\tif(nums[i]>nums[i+1])right[i]=right[i+1]+1;\n\t\t\t}       \n\t\t\tint s=0;\n\t\t\tfor(int i=0;i<n;i++)\n\t\t\t{\n\t\t\t   s+=max(left[i],right[i]);\n\t\t\t}\n\t\t   return s;\n\t\t\t}\n\t\t};
['Array', 'Greedy', 'C', 'C++']