Maximum Subarray Sum Modulo M | HackerRank Solution | Algorithm Explanation by alGOds!!

preview_player
Показать описание
In this video, V Sriram has explained the optimized approach for solving the question #MaximumSubarraySum from #Hackerrank in O(nlogn) time complexity.

Feel free to ask any of your doubts and discuss your attempts related to this question in the comments section 😇.

Do like and subscribe to our channel and click the bell icon so you don’t miss any future videos!!.
Don’t forget to tell us about the Questions you need an explanatory video for in the comments section. We’ll definitely take care of it😁.

The contributors to this channel and their profile links are enlisted below

1) Vishesh Aggarwal:
2) Vaibhav Varshney:
3) Vagish Yagnik:
4) Vishesh Jain:
5) Achint Dawra:
6) V Sriram:
7) Varun Bajlotra:
8) Vikas Yadav:
Рекомендации по теме
Комментарии
Автор

At 3:31
34 + 11 = 43.
Wao, what a programmer!!

jayeshsolanki
Автор

your explanation is very read many articles on this problem, but i couldn't get their video cleared my doubts...Thanks a lot .

tarungopal
Автор

Today I realized views cannot decide the quality of content. Great work bro

harshsoni
Автор

Wow sir I'm not studying science but still find this useful. Thank you sir

aradhyasharma
Автор

A very lucid and clear explanation.Hope you can start a series too on Algorithms. Thank you:)

ujwalkumar
Автор

one doubt sir iam not computer stream student, the way you used to solve the problem is amazing how i can think like that

padmanabhankum
Автор

sir thank you so much providing the solution, your explanation is very clear for each and every concept.

cheshtaagrawal
Автор

In Modulo sum M problem as per codeforce, we generally try to find the whether there is any sequence from n numbers are divisible by m. So as per tabular approach, we check whether dp[n][0] is true o not to conclude. Then how can we find the modulo sum sub sequence from this table? It is easy to trace back the subsequence for maximum subarray sum dp table. Is there any similar approach for modulo sum M sub sequence?

kaustuvchatterjee
Автор

You have got a subscriber today. Very detailed explanation.♥️👌

sumondey
Автор

I think you are skipping over the most important part of the problem here 13:50.

without doing something very custom, I am not aware of any SORTED set data structures that allow you to get by index. This would be required to implement the algorithm to "fetch the smallest number that is larger than the target number." SET data sources of this type can only fetch a SPECIFIC value if it exists.

brianc
Автор

Thank you sir! Love you sir! Your videos are really awesome sir ji!

ananyapamde
Автор

Thanks a lot for the explanation I really need this a lot. A very nice explanation

mohitraj
Автор

For input [ 3, 3, 9, 9, 5 ], applying your logic will give the output 5. However, the correct output is 6.

kc
Автор

can you please upload the commented code or please upload the video of explaining the code because I understood your approach but i am unable to understand the code
Thanks in advance :)

jgsquare
Автор

how do you find the smallest larger one in prefix sum, doesn't the search in step push up the complexity?

ferrytang
Автор

while compiling -8%15 its show -8 not 7 . AT 1:31

ShubhamKumar-fyfl
Автор

Bro how you knew this formula of sum ?

ytg
Автор

Hi, thanks for the explanation. I still don't understand however why adaptation of Kadane's algorithm cannot be used. Can you please clarify? "Wrapping around" m does not seem like a reason. Can you provide an input where it fails?
Say:
long max = a[0];
long globalMax = max % m;

for(int i=1; i<a.length; i++) {
max = Math.max((max % m + a[i] % m) % m, a[i] % m );
if(max >globalMax ) globalMax = max;
}

return globalMax;

a = [3 6 2 4 5]
m = 7
max: 3->6->2->4->5
globalMax = 6

codoBlast
Автор

My question is little different .. I want to return maximum sum subarray. Output should be an sub-array whose sum is maximum.
example : if input is [-2, -1, 0, 4, -1, 2, 1, -3, 2] then output should be [4, -1, 2, 1]

sasmitbhanu
Автор

As explained in the video, if maximum subarray sum can be obtained by adding until the sum becomes 0 and starting over, what is the maximum subarray sum of this array 1, 3, -4, 0 ?

udaybhaskarnamburu
visit shbcf.ru