LeetCode 2640 Find the Score of All Prefixes of An Array Fully Explained Easy Approach Prefix Sum

preview_player
Показать описание

Before going for code give a try by looking at the intuition in the video, pause for a while and think about the solution.
It is a quite simple and intuitive approach, we need to just make sure have the maximum of the previous elements and the prefix sum.
That means if the array = 2, 7, 5 , 10
Then the maximum till the index is = 2, 7, 7, 10

But we need to return an array which contains the presum and the maximum element till that index

So to solve this problem we need to just initialize the maximumElement and the prefixSum and psuh back the converted element into converted array
Then return converted array
If you have come till here, I think you are making a mistake without subscribing to my channel
Рекомендации по теме
visit shbcf.ru