Prefix Sums - Problems, Code in C++ & Python

Поділитися
Вставка
  • Опубліковано 8 вер 2024
  • Prefix sums are the sums of the first K elements in an array. You can use them to quickly get the range sum and solve many other problems.
    Range Sum - cses.fi/proble... or www.spoj.com/p...
    Most Frequent - www.geeksforge...
    Range Increase - www.hackerrank...
    Subarray Sum Equals K - leetcode.com/p...
    Product - leetcode.com/p...
    CF article - codeforces.com...
    I stream on Twitch - / errichto
    2nd YT channel - / errichto2

КОМЕНТАРІ • 109

  • @kartikeysingh8376
    @kartikeysingh8376 Рік тому +49

    Long time no see
    happy that you are back 🙂
    please make videos continuously ,it helps a lot

  • @tle-dewcodes7166
    @tle-dewcodes7166 Рік тому +42

    Finally Errichto remembers,
    That he has a UA-cam channel😅

  • @mihiradarsh7604
    @mihiradarsh7604 Рік тому +48

    Finally he is here👏👏

  • @caiodavi9829
    @caiodavi9829 Рік тому +12

    no way!!! i was looking for this video last week, but i saw you had not uploaded in a long time… what a nice timing. welcome back, errichto!🎉🎉

  • @GospodinStanoje
    @GospodinStanoje Рік тому +7

    Thanks for posting again! I really appreciate your videos. Your voice is calm and you're gifted in explaining it simply.
    Greetings from Serbia.

  • @coldxwave
    @coldxwave Рік тому +6

    Glad you're back!!!

  • @jlecampana
    @jlecampana Рік тому +1

    Your lectures are fantastic, just the right amount of theoretical foundation and then a code dive-in, very well done, keep 'em coming Mr. Errichto!

  • @abdo_omareg
    @abdo_omareg Рік тому +1

    I watched the binary search video and solved the problem you mentioned and more, and I will try to do that on this one again, and soon I will watch your dynamic programming series and solve them.
    Thank you so much for your guidance and I hope you upload more because they are great and straightforward

    • @zanies6288
      @zanies6288 Рік тому

      If you are really interested in learning and have some free time. You should watch videos (previously recorded livestream) from Colin galen and Vivek gupta.

    • @abdo_omareg
      @abdo_omareg Рік тому

      @@zanies6288 thank you so much for the recommendations, I really appreciate it and I will grind to solve and learn from them

  • @malekissa1771
    @malekissa1771 Рік тому +5

    We missed you so much

  • @sachinkahawala7764
    @sachinkahawala7764 Рік тому +4

    Errichto is back! ❤️

  • @user-gk2os6vt8u
    @user-gk2os6vt8u Рік тому

    Finally you are back , i used to watch your videos when i eat food , finally again some great content . Love you man ....

  • @DrKeK-gh6sm
    @DrKeK-gh6sm Рік тому +1

    Thank you so much errichto, i was just looking for prefix/suffix sums for the last few days

  • @akramelomrani8728
    @akramelomrani8728 Рік тому +6

    Errichto remembered his gmail password at last.

  • @detective1723
    @detective1723 Рік тому +5

    He is back!🎉

  • @abdo_omareg
    @abdo_omareg Рік тому

    Thank you for sharing this video! Your demonstration of the algorithm is amazing and straight forward with easy and hard problems, couldn't ask for a better video, thank you!

  • @amreezkhan5530
    @amreezkhan5530 Рік тому +4

    He is backkk🎉🎉🎉🎉🎉🎉🎉🎉🎉🎉❤❤❤❤

  • @abc_cba
    @abc_cba 2 місяці тому

    Miss your content. I wish you come back.
    Best wishes from India

  • @tetrreter6548
    @tetrreter6548 Рік тому +1

    it's too time to see you again 🎉 I'm so happy ❤

  • @awgzmp
    @awgzmp Рік тому +12

    Does anyone know what does:
    *ios_base::sync_with_stdio(0);*
    and
    *cin.tie(0);*
    mean?

    • @Errichto
      @Errichto  Рік тому +7

      In short, it makes cin/cout faster.

    • @therealpancake7140
      @therealpancake7140 Рік тому

      @@Errichto Is it actually any better than using scanf() and printf()? I've done some testing myself and found that cin/cout with the boost are faster but I've also found conflicting results on the internet. What's your experience with the two approaches

    • @piaIy
      @piaIy 11 місяців тому

      ​@@therealpancake7140 streams work with std::string, which makes them easier to use.

  • @rajmittal5394
    @rajmittal5394 Рік тому +4

    Legend comes🎉🎉🎉

  • @mahmoudel-hawawshy5198
    @mahmoudel-hawawshy5198 Рік тому

    Thank you for posting educational content, I am really grateful and sure that most people appreciate your content so much too.
    please keep posting whenever you can, Thank you again!

  • @atifayaz3495
    @atifayaz3495 8 місяців тому +1

    0:00 What is prefix sums?
    4:31 Problem 1 : Static range sum queries
    7:09 Problem 2 : Most common character in the substring
    15:41 Problem 3 : Array manipulation 🤯
    18:49 Summary

  • @blagojrs
    @blagojrs Рік тому +3

    The legend's back!

  • @inde_t
    @inde_t Місяць тому

    still haven't studied 2d prefix sum because i've been waiting for your video

  • @mahadihassan1342
    @mahadihassan1342 Рік тому +1

    Finally he is back after a long time 😊.

  • @ADITYAKUMAR-tb4gm
    @ADITYAKUMAR-tb4gm Рік тому

    Heyyy, very nice to see you back. I've learnt so many stuffs from you

  • @sharp615
    @sharp615 Рік тому

    The man himself is back at it again. Nice to have you back

  • @rimurusama5070
    @rimurusama5070 Рік тому

    Loved to see your content once again. Thanks you so much.

  • @Jeggettmega
    @Jeggettmega Рік тому

    Thanks for the video! That type of content I find the most useful.

  • @vesperflix2211
    @vesperflix2211 11 місяців тому

    the way you teach is perfect

  • @goldenlin9528
    @goldenlin9528 Рік тому

    Welcome back, glad to see u posting again

  • @MehbubulHasanAlQuvi
    @MehbubulHasanAlQuvi Рік тому +2

    After long time!

  • @abdullahsaid4765
    @abdullahsaid4765 Рік тому

    welcome bruh I'm happy to see you long time no see

  • @iceman4404
    @iceman4404 Рік тому +2

    The chosen one is back

  • @madsbdkerchristensen9597
    @madsbdkerchristensen9597 Рік тому

    Love your videos, was hoping you would post again soon :)

  • @haxortaxor8736
    @haxortaxor8736 Рік тому

    man im so happy you are back!

  • @juancastaneda5062
    @juancastaneda5062 Рік тому

    Excellent that you get back....¡¡¡¡¡¡

  • @yevengyklaus7066
    @yevengyklaus7066 Рік тому +2

    The myth the man the legend.

  • @user-ku6km4ou8q
    @user-ku6km4ou8q Рік тому +2

    In the last problem can we just put a if statement that adds x if i is in range l to r please correct me if i am wrong
    And also as some one who just cp is a2oj a good resource or should i do something else also

    • @Errichto
      @Errichto  Рік тому +1

      If you do it separately for each of Q updates, the total time complexity is O(N*Q), which is too slow.
      a2oj is ok as long as you solve problems that are difficult enough for you.

    • @user-ku6km4ou8q
      @user-ku6km4ou8q Рік тому

      @@Errichto Thank you very much for your guidance 👍😊

  • @shiva_singh1700
    @shiva_singh1700 Рік тому

    Good to see u back😊

  • @user-kn3xh3um8h
    @user-kn3xh3um8h Рік тому

    Glad to see you're back🤩

  • @WiseWords581
    @WiseWords581 9 місяців тому

    Very Helpful 👍🏾 Thank you sir

  • @sepehr__byt
    @sepehr__byt Рік тому

    I'm glad to see you again

  • @shail_
    @shail_ 11 місяців тому

    Thanks for the fantastic content!🌻

  • @karangarg7004
    @karangarg7004 Рік тому

    Thank you so muuch for all of this!!❤

  • @akashkishoremukhia7888
    @akashkishoremukhia7888 Рік тому

    Keep on teach us erricto.🔥🔥

  • @rodhash
    @rodhash Рік тому

    wow you are back! we missed you bro

  • @wesleyso0
    @wesleyso0 Рік тому +1

    YAY! ERRICHTO'S BACK!

  • @Algorithmswithsubham
    @Algorithmswithsubham Рік тому +1

    happy to see that you are so back

  • @sakibsidha
    @sakibsidha Рік тому +1

    LET'S GOOOOOO! LOOK WHO'S HEREEE

  • @rahuldasari1886
    @rahuldasari1886 Рік тому

    Pls make some more videos like this
    Thank you

  • @nilu-bp6mv
    @nilu-bp6mv Рік тому

    very happy to see you 😊❤

  • @pj-nz6nm
    @pj-nz6nm Рік тому +1

    After a long time.

  • @jasveersingh01
    @jasveersingh01 Рік тому

    The legend is back guys.❤❤❤❤❤❤

  • @OrifxonHusanov
    @OrifxonHusanov Рік тому +1

    Legends never die!🙂

  • @TheJohnniePlays
    @TheJohnniePlays Рік тому +4

    Can you make a tutorial on problem solving. Like picking a harder problem and showing how to come up with some initial observations and ideas and work trough them to come up with a solution. A lot of times I just end up with a blank screen having difficulty even understanding what the problem is about.

    • @Errichto
      @Errichto  Рік тому +9

      I have hundreds of videos & streams about problem solving across my two channels. I rarely solve anything without explaining the thought process. If you want to see me struggle for hours, see any Atcoder Grand Contest streams like this one ua-cam.com/video/UJrzgjblMCM/v-deo.html

    • @TheJohnniePlays
      @TheJohnniePlays Рік тому +2

      @@Errichto This is it. Thank you.

  • @milanboroja7094
    @milanboroja7094 Рік тому +2

    Hi from Banja Luka

  • @Grainme47
    @Grainme47 Рік тому

    yeah same request : Please make more videos :)

  • @rifatchowdhury3683
    @rifatchowdhury3683 Рік тому

    Finally,,,, After A Long Time❤

  • @jenwans3055
    @jenwans3055 Рік тому

    Welcome back man 🔥🤜

  • @ayush_sccg8674
    @ayush_sccg8674 Рік тому

    I guess you will be uploading about algorithms now that's gonna be good

  • @user-pi2zd4xj8z
    @user-pi2zd4xj8z 6 місяців тому

    The best tutor

  • @ashwani_kumar_rai
    @ashwani_kumar_rai Рік тому

    He man thanks please be regular

  • @alkhawarizm780
    @alkhawarizm780 3 місяці тому

    sir please made a video for setup far manager

  • @Business_Adviser258
    @Business_Adviser258 Рік тому

    Long time no see

  • @oximas-oe9vf
    @oximas-oe9vf 2 місяці тому

    why dont we just go through the range form a to b and up the elements
    instead of summing from 0 to b then from 0 to a and taking the prior minus the latter?

  • @user-nt2lt7pm3z
    @user-nt2lt7pm3z Рік тому

    Top G is back 😌

  • @theAZ1X
    @theAZ1X Рік тому

    Good day Errichto! I have question. ( 10:00 )
    at the 7 line :
    s is string
    s.length() = s.size() ?

  • @irvin1241
    @irvin1241 Рік тому

    long time no see😂

  • @ingcivil-upm
    @ingcivil-upm 4 місяці тому

    more videoss please

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

    Brother can you recommend me which book r best for DSA and competative programming. Ik practice is the key but please recommend me 😊

  • @SadriddinDusanov
    @SadriddinDusanov Рік тому

    raxmat bro

  • @DrFranzovic
    @DrFranzovic Рік тому

    hello errichto i am currently on a search for a new laptop for CP and i wanted to know if you got any advices for choosing the right one?

  • @Moch117
    @Moch117 Рік тому

    Does this method work for suffix as well , where we use an array of size + 1? I ran into some errors

  • @Liux2040
    @Liux2040 Рік тому

    Finally!!! I missed you😅

  • @spideyboy3587
    @spideyboy3587 11 місяців тому

    What's the device that you are using to write in screen ?
    Can you please answer.

  • @SabarMohamed
    @SabarMohamed Рік тому +1

    It's been a while 😭

  • @aisha9763
    @aisha9763 11 місяців тому

    Hello kindly hear guys , this is stay-at -home mum , Could I ask for C++, which laptop or computer required? Which one is best ? Which application or soft need to install ( now we use Mac) - thank you so much for your assistance.

    • @aisha9763
      @aisha9763 11 місяців тому

      Good-hearted guys

    • @adib7143
      @adib7143 9 місяців тому

      @aisha9763, I don't use mac but hope this helps ua-cam.com/video/1E_kBSka_ec/v-deo.htmlsi=H77gcqle7X-EVWOy

  • @lazyemperor5182
    @lazyemperor5182 Рік тому

    More videos please

  • @stati5tik
    @stati5tik 8 місяців тому

    first problem is basically what integral images are about.

  • @abrarmasumabir3809
    @abrarmasumabir3809 Рік тому

    Where did you set pref[0] = 0. Sorry if it is stupid to ask!

  • @georgedrooj8800
    @georgedrooj8800 Рік тому

    Finally 😍😍😍

  • @nightsusmare8468
    @nightsusmare8468 10 місяців тому +2

    polska gurom

  • @elghalib2209
    @elghalib2209 2 місяці тому

    still waiting for 2d prefix sums :(

  • @hassanali-il3rk
    @hassanali-il3rk Рік тому

    can i ask hint to hackerrank problem?

  • @lazyemperor5182
    @lazyemperor5182 Рік тому

    More edu videos please

  • @VP-es6wy
    @VP-es6wy Рік тому

    Will you be posting regularly?

  • @surajshekhar17
    @surajshekhar17 11 місяців тому

    ✨💫

  • @kartik4792
    @kartik4792 Рік тому +1

    3 views 13 likes!

  • @AsherDMckoy
    @AsherDMckoy Рік тому

    Do you still do tutoring?

    • @Errichto
      @Errichto  Рік тому

      I do. You can find my email id in the "About" section on UA-cam.

  • @richardharris202
    @richardharris202 Рік тому

    😶‍🌫️✨

  • @mirza5635
    @mirza5635 Рік тому

    Eat burger

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

    dawaj tyeraz po polsku

  • @camperjett
    @camperjett Рік тому

    Can this comment get pinned?

  • @quocanhhbui8271
    @quocanhhbui8271 Рік тому +1

    the legend is back!