Prefix Sum Array Explained

แชร์
ฝัง
  • เผยแพร่เมื่อ 5 ม.ค. 2025

ความคิดเห็น • 43

  • @gatusko123
    @gatusko123 2 ปีที่แล้ว +11

    This damn problem on LeetCode. Reading and trying to understand the solutions. But this video is the best one and the one finally understand it. Thank you very much man.

  • @kender2272
    @kender2272 ปีที่แล้ว +8

    thank you, very well and simply explained, I'm writing my final school leaving exam soon, and I'm extending computer science(in my country you can choose extended additional subjects).

  • @walthertrgovac6087
    @walthertrgovac6087 4 ปีที่แล้ว +25

    You explained that really good, thank you! It helped me a lot :D

  • @jeyburns.t9209
    @jeyburns.t9209 หลายเดือนก่อน

    Finally someone who explains this simple

  • @rauljg143
    @rauljg143 4 ปีที่แล้ว +3

    Great explanation. Thank you. "Prefix sum" kept coming in the context of loop-unrollling and I'm like "back up. what's a prefix sum???" Now I get it and can move on!

    • @aakashtiwari836
      @aakashtiwari836 4 ปีที่แล้ว

      In which course and in which year you are???

    • @almuhimen8023
      @almuhimen8023 4 ปีที่แล้ว

      What is loop unrolling?

    • @MiketheCoder
      @MiketheCoder  3 ปีที่แล้ว

      loop unrolling is when you try to unroll the loop in assembly to make it more efficient, that's super exhausting to do though

  • @dThapa966
    @dThapa966 ปีที่แล้ว +3

    This was explained extremely well. Thank you very much !!

  • @Relatable_coder
    @Relatable_coder 6 หลายเดือนก่อน

    Giving a codeforces contest ,this really came in clutch,Great work!!

  • @taal7245
    @taal7245 3 ปีที่แล้ว +14

    damn.. I just want to grab that pencil right off his hands, sharpen it. Then give it back to him!

  • @sunnyday12131
    @sunnyday12131 3 ปีที่แล้ว +2

    Thanks for this, finally I got to know what prefix sum is and helps me solve leetcode 370!

  • @justmeandmy
    @justmeandmy 8 หลายเดือนก่อน +2

    What I'm struggling with is understanding how and when to use it for things beyond the prefix sum algo itself. eg - I know that facebook coding puzzle Director of Photography can be used to solve it, but I still don't really understand how to spot the use cases.

  • @pranavsudhir7645
    @pranavsudhir7645 4 ปีที่แล้ว +1

    Amazing explanation Michael. Great job. Subscribed to your channel.

  • @KevinBuii
    @KevinBuii 3 หลายเดือนก่อน

    Great explanation thank you!

  • @thisjoman
    @thisjoman 4 ปีที่แล้ว +6

    love you bro

  • @abrarmasumabir3809
    @abrarmasumabir3809 2 ปีที่แล้ว

    Thanks brother! That was really cool!

  • @ohmegatech666
    @ohmegatech666 2 หลายเดือนก่อน

    So it's just caching / memoizing for one speicific function (getting prev sum) basically

  • @egecalskan6355
    @egecalskan6355 4 ปีที่แล้ว

    This video was very helpful, thank you!

  • @mirsahib596
    @mirsahib596 10 หลายเดือนก่อน +1

    So prefix sum is basically a version of sliding window technique

  • @prajwalchoudhary4824
    @prajwalchoudhary4824 4 ปีที่แล้ว +2

    great explanation

    • @MiketheCoder
      @MiketheCoder  4 ปีที่แล้ว +3

      Thank you!!

    • @juliancruz87
      @juliancruz87 4 ปีที่แล้ว

      @@MiketheCoder you're such a great teacher explaining it!

  • @Computervirusworld
    @Computervirusworld 12 วันที่ผ่านมา

    thanks bro

  • @atulkrjha
    @atulkrjha ปีที่แล้ว +1

    Hi Mike great video, So i am like little confused if it is given to calculate sum between 2 indexes except 0 i.e sum between 3 to 5 index why do we do PS[5] - PS[3-1] and not PS[5] - PS[3]

    • @MiketheCoder
      @MiketheCoder  ปีที่แล้ว +2

      It's because sometimes people like to start their prefix sum as value 0 first or not.
      Let's say you have:
      Arr: [1, 2, 3, 4, 5, 6]
      Pref: [1, 3,6, 10, 15, 21]
      Sum index 3 to 5:
      4 + 5 + 6 = 15
      To get that you need to do: 21 - 6 = pref[5] - pref[2]
      But if you start your prefix sum at 0:
      Pref: [0, 1, 3, 6, 10, 15, 21]
      21 - 6 = pref[5 + 1] - pref[3]
      It depends how you want to start your prefix sum

    • @atulkrjha
      @atulkrjha ปีที่แล้ว

      @@MiketheCoder Isn't our prefixSum would have length > than our original array if we start from 0?

    • @MiketheCoder
      @MiketheCoder  ปีที่แล้ว +1

      @@atulkrjha Yup, it really depends on the individual how they want to code it.

  • @Yazan_Majdalawi
    @Yazan_Majdalawi ปีที่แล้ว

    Thanks!

  • @srajputplays8054
    @srajputplays8054 ปีที่แล้ว

    noice😊

  • @bahrawy07
    @bahrawy07 2 ปีที่แล้ว +1

    man ily

  • @xpluto13x
    @xpluto13x 3 ปีที่แล้ว

    Saved me. Thank you

  • @mandeepkhadka388
    @mandeepkhadka388 4 ปีที่แล้ว +2

    Can you also make a video on implementing a parallel version of Prefix Sum?

    • @MiketheCoder
      @MiketheCoder  4 ปีที่แล้ว

      With multithreading???? Maybe. I’ll think about it.

  • @سلمىخالدمحمدراشد
    @سلمىخالدمحمدراشد 3 ปีที่แล้ว +2

    great explanation