Maximum Contiguous Subsequence - Dynamic Programming

Поділитися
Вставка
  • Опубліковано 5 лис 2024

КОМЕНТАРІ • 25

  • @fitoor0997
    @fitoor0997 9 років тому +13

    beautifully explained!!! saved a lot of time of mine..

  • @JayPatel12928
    @JayPatel12928 5 років тому +2

    I want you to know that, among all the explanations on youtube, your's is the best one.

  • @neobonzi
    @neobonzi 7 років тому

    By far the best explanation of the cost function out of all the videos I've seen on youtube

    • @jackkalman8195
      @jackkalman8195 7 років тому

      too bad its wrong. [-1,-2] is the counter example.

    • @AjayByadgi
      @AjayByadgi 7 місяців тому

      @@jackkalman8195 lol noob he said if its all negative just take the largest value (-1) in the list

  • @sbonelo
    @sbonelo 8 років тому +6

    Extremely helpful, thank you so much

  • @SmartProgramming
    @SmartProgramming 6 років тому

    awesome explanation, keep it up, thank you 👍👍🙂🙂

  • @KrishanuKonar
    @KrishanuKonar 8 років тому +2

    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).

  • @ffatheranderson
    @ffatheranderson 5 років тому

    Thank you. Very good explanation.

  • @sabio234
    @sabio234 8 років тому +1

    Do you have any which teaches how to come up with a formula to solve DP ?

  • @jasdn93bsad992
    @jasdn93bsad992 5 років тому

    A[i] could be a negative number, in taht case, S[i] = S[i-1];

  • @kameshsriram
    @kameshsriram 6 років тому +1

    I think the problem you are solving is Maximum contiguous sub-array but not Maximum Contiguous Subsequence

  • @technomissilecraft4532
    @technomissilecraft4532 8 років тому

    please upload travelling salesman problem,Bellman Ford algorithm.

  • @thanga2317
    @thanga2317 5 років тому

    is this subsequence or subarray ? if its subsequence then answer should be 2 + 3 + 5 = 10. correct me if am wrong .

    • @RooonilWazlib
      @RooonilWazlib 5 років тому

      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.

  • @PreethaDatta
    @PreethaDatta 8 років тому

    how would you define s? the code in c++ that is

  • @eithanmartinez2852
    @eithanmartinez2852 4 роки тому

    Do you have the pseudocode?

  • @chuongxl
    @chuongxl 6 років тому

    great :) thank!

  • @groupsvkg
    @groupsvkg 7 років тому

    For A = [-6, 2, -4]
    S(2) = -2 or 2 ?

    • @jackkalman8195
      @jackkalman8195 7 років тому

      his algorithm is wrong lol.. idk why so many ppl thumbed up

    • @oliverliu9205
      @oliverliu9205 7 років тому +2

      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.

    • @matheusrotta1589
      @matheusrotta1589 6 років тому

      His algorithm is correct, you take the maximum in the array afterwards.

    • @ffatheranderson
      @ffatheranderson 5 років тому

      @@jackkalman8195 it works perfect for me.

  • @jackkalman8195
    @jackkalman8195 7 років тому

    Bro what about this input [-1,-2]? your algorithm returned -2 and obviously the answer should be -1 lol

    • @oliverliu9205
      @oliverliu9205 7 років тому +3

      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.