I want you to know that, among all the explanations on youtube, your's is the best one.
@fitoor09979 жыл бұрын
beautifully explained!!! saved a lot of time of mine..
@neobonzi7 жыл бұрын
By far the best explanation of the cost function out of all the videos I've seen on youtube
@jackkalman81957 жыл бұрын
too bad its wrong. [-1,-2] is the counter example.
@AjayByadgi8 ай бұрын
@@jackkalman8195 lol noob he said if its all negative just take the largest value (-1) in the list
@sbonelo8 жыл бұрын
Extremely helpful, thank you so much
@SmartProgramming6 жыл бұрын
awesome explanation, keep it up, thank you 👍👍🙂🙂
@KrishanuKonar8 жыл бұрын
What happens when when two sub-sequences generate same sum?? Should we take the longer one or the shorter one? Marking the number red would only give the most recent solution(subsequence).
@sabio2348 жыл бұрын
Do you have any which teaches how to come up with a formula to solve DP ?
@ffatheranderson5 жыл бұрын
Thank you. Very good explanation.
@eithanmartinez28524 жыл бұрын
Do you have the pseudocode?
@PreethaDatta8 жыл бұрын
how would you define s? the code in c++ that is
@technomissilecraft45328 жыл бұрын
please upload travelling salesman problem,Bellman Ford algorithm.
@thanga23175 жыл бұрын
is this subsequence or subarray ? if its subsequence then answer should be 2 + 3 + 5 = 10. correct me if am wrong .
@RooonilWazlib5 жыл бұрын
Contiguous means you can't skip anything in the sequence. You have a starting index and an ending index and take the sum of all the values within that subsequence.
@groupsvkg7 жыл бұрын
For A = [-6, 2, -4] S(2) = -2 or 2 ?
@jackkalman81957 жыл бұрын
his algorithm is wrong lol.. idk why so many ppl thumbed up
@oliverliu92057 жыл бұрын
S(0) = -6, S(1) = either -6 + 2 or 2, we will take 2. S(2) = either 2 - 4, or -4. We will take 2-4 = -2. But now you take the maximum number from this array, so the final answer is 2.
@matheusrotta15896 жыл бұрын
His algorithm is correct, you take the maximum in the array afterwards.
@ffatheranderson5 жыл бұрын
@@jackkalman8195 it works perfect for me.
@kameshsriram6 жыл бұрын
I think the problem you are solving is Maximum contiguous sub-array but not Maximum Contiguous Subsequence
@jasdn93bsad9925 жыл бұрын
A[i] could be a negative number, in taht case, S[i] = S[i-1];
@chuongxl6 жыл бұрын
great :) thank!
@jackkalman81957 жыл бұрын
Bro what about this input [-1,-2]? your algorithm returned -2 and obviously the answer should be -1 lol
@oliverliu92057 жыл бұрын
His algorithm is right and yourself are wrong. the solution array would be: [-1,-2] But now you take the maximum number from this array, which is -1. Remember, S[i] is the largest contiguous sum you can get ENDING AT (NOT UP TO) index i. Therefore you cannot simply take the last element in the solution array.