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

Sdílet
Vložit
  • čas přidán 27. 06. 2023
  • 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/problemset/task/1646 or www.spoj.com/problems/CSUMQ/
    Most Frequent - www.geeksforgeeks.org/queries...
    Range Increase - www.hackerrank.com/challenges...
    Subarray Sum Equals K - leetcode.com/problems/subarra...
    Product - leetcode.com/problems/product...
    CF article - codeforces.com/blog/entry/86420
    I stream on Twitch - / errichto
    2nd YT channel - / errichto2

Komentáře • 107

  • @tle-dewcodes7166
    @tle-dewcodes7166 Před 10 měsíci +30

    Finally Errichto remembers,
    That he has a CZcams channel😅

  • @mihiradarsh7604
    @mihiradarsh7604 Před 10 měsíci +39

    Finally he is here👏👏

  • @caiodavi9829
    @caiodavi9829 Před 10 měsíci +9

    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!🎉🎉

  • @kartikeysingh8376
    @kartikeysingh8376 Před 10 měsíci +40

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

    • @noomade
      @noomade Před 7 měsíci +1

      Is he back or is this not a repost?

  • @jlecampana
    @jlecampana Před 10 měsíci +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!

  • @GospodinStanoje
    @GospodinStanoje Před 10 měsíci +6

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

  • @abdo_omareg
    @abdo_omareg Před 10 měsíci

    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!

  • @akramelomrani8728
    @akramelomrani8728 Před 10 měsíci +6

    Errichto remembered his gmail password at last.

  • @sodbayarnanjidjamts7457
    @sodbayarnanjidjamts7457 Před 10 měsíci +6

    Glad you're back!!!

  • @DrKeK-gh6sm
    @DrKeK-gh6sm Před 10 měsíci +1

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

  • @malekissa1771
    @malekissa1771 Před 10 měsíci +5

    We missed you so much

  • @haxortaxor8736
    @haxortaxor8736 Před 10 měsíci

    man im so happy you are back!

  • @detective1723
    @detective1723 Před 10 měsíci +5

    He is back!🎉

  • @Jeggettmega
    @Jeggettmega Před 10 měsíci

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

  • @shail_
    @shail_ Před 7 měsíci

    Thanks for the fantastic content!🌻

  • @user-gk2os6vt8u
    @user-gk2os6vt8u Před 9 měsíci

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

  • @sachinkahawala7764
    @sachinkahawala7764 Před 10 měsíci +4

    Errichto is back! ❤️

  • @goldenlin9528
    @goldenlin9528 Před 9 měsíci

    Welcome back, glad to see u posting again

  • @user-kn3xh3um8h
    @user-kn3xh3um8h Před 10 měsíci

    Glad to see you're back🤩

  • @tetrreter6548
    @tetrreter6548 Před 10 měsíci +1

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

  • @sharp615
    @sharp615 Před 10 měsíci

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

  • @mahadihassan1342
    @mahadihassan1342 Před 10 měsíci +1

    Finally he is back after a long time 😊.

  • @blagojrs
    @blagojrs Před 10 měsíci +3

    The legend's back!

  • @mahmoudel-hawawshy5198
    @mahmoudel-hawawshy5198 Před 9 měsíci

    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!

  • @shiva_singh1700
    @shiva_singh1700 Před 10 měsíci

    Good to see u back😊

  • @abdullahsaid4765
    @abdullahsaid4765 Před 10 měsíci

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

  • @ADITYAKUMAR-tb4gm
    @ADITYAKUMAR-tb4gm Před 10 měsíci

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

  • @sepehr__byt
    @sepehr__byt Před 10 měsíci

    I'm glad to see you again

  • @subhamcoder
    @subhamcoder Před 10 měsíci +1

    happy to see that you are so back

  • @vesperflix2211
    @vesperflix2211 Před 7 měsíci

    the way you teach is perfect

  • @amreezkhan5530
    @amreezkhan5530 Před 10 měsíci +4

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

  • @jenwans3055
    @jenwans3055 Před 10 měsíci

    Welcome back man 🔥🤜

  • @nilu-bp6mv
    @nilu-bp6mv Před 10 měsíci

    very happy to see you 😊❤

  • @karangarg7004
    @karangarg7004 Před 10 měsíci

    Thank you so muuch for all of this!!❤

  • @madsbdkerchristensen9597
    @madsbdkerchristensen9597 Před 9 měsíci

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

  • @rajmittal5394
    @rajmittal5394 Před 10 měsíci +4

    Legend comes🎉🎉🎉

  • @jasveersingh01
    @jasveersingh01 Před 10 měsíci

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

  • @rodhash
    @rodhash Před 10 měsíci

    wow you are back! we missed you bro

  • @abdo_omareg
    @abdo_omareg Před 10 měsíci +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 Před 9 měsíci

      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 Před 9 měsíci

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

  • @quocanhhbui8271
    @quocanhhbui8271 Před 10 měsíci +1

    the legend is back!

  • @akashkishoremukhia7888
    @akashkishoremukhia7888 Před 10 měsíci

    Keep on teach us erricto.🔥🔥

  • @rifatchowdhury3683
    @rifatchowdhury3683 Před 10 měsíci

    Finally,,,, After A Long Time❤

  • @juancastaneda5062
    @juancastaneda5062 Před 10 měsíci

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

  • @WiseWords581
    @WiseWords581 Před 5 měsíci

    Very Helpful 👍🏾 Thank you sir

  • @MehbubulHasanAlQuvi
    @MehbubulHasanAlQuvi Před 10 měsíci +2

    After long time!

  • @iceman4404
    @iceman4404 Před 10 měsíci +2

    The chosen one is back

  • @Moch117
    @Moch117 Před 8 měsíci

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

  • @rahuldasari1886
    @rahuldasari1886 Před 10 měsíci

    Pls make some more videos like this
    Thank you

  • @sakibsidha
    @sakibsidha Před 10 měsíci +1

    LET'S GOOOOOO! LOOK WHO'S HEREEE

  • @yevengyklaus7066
    @yevengyklaus7066 Před 10 měsíci +2

    The myth the man the legend.

  • @OrifxonHusanov
    @OrifxonHusanov Před 10 měsíci +1

    Legends never die!🙂

  • @ashwani_kumar_rai
    @ashwani_kumar_rai Před 10 měsíci

    He man thanks please be regular

  • @wesleyso0
    @wesleyso0 Před 10 měsíci +1

    YAY! ERRICHTO'S BACK!

  • @Liux2040
    @Liux2040 Před 10 měsíci

    Finally!!! I missed you😅

  • @Grainme47
    @Grainme47 Před 10 měsíci

    yeah same request : Please make more videos :)

  • @awgzmp
    @awgzmp Před 10 měsíci +12

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

    • @Errichto
      @Errichto  Před 10 měsíci +7

      In short, it makes cin/cout faster.

    • @therealpancake7140
      @therealpancake7140 Před 10 měsíci

      @@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 Před 8 měsíci

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

  • @user-pi2zd4xj8z
    @user-pi2zd4xj8z Před 2 měsíci

    The best tutor

  • @daveshub
    @daveshub Před 3 měsíci

    Hi Errichto. I was thinking that the prefix sum might not be the fastest for the string problem you mentioned in the video. I'm not quite sure yet because I don't feel like putting my idea in code to test it out. But thanks for the video anyways. It was really helpful

  • @irvin1241
    @irvin1241 Před 10 měsíci

    long time no see😂

  • @ayush_sccg8674
    @ayush_sccg8674 Před 10 měsíci

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

  • @user-nt2lt7pm3z
    @user-nt2lt7pm3z Před 10 měsíci

    Top G is back 😌

  • @spideyboy3587
    @spideyboy3587 Před 8 měsíci

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

  • @georgedrooj8800
    @georgedrooj8800 Před 10 měsíci

    Finally 😍😍😍

  • @DrFranzovic
    @DrFranzovic Před 10 měsíci

    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?

  • @pj-nz6nm
    @pj-nz6nm Před 10 měsíci +1

    After a long time.

  • @SadriddinDusanov
    @SadriddinDusanov Před 10 měsíci

    raxmat bro

  • @adu1aziz_698
    @adu1aziz_698 Před 10 měsíci

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

  • @The_Ironman_3000
    @The_Ironman_3000 Před 10 měsíci

    Long time no see

  • @TheViral_fyp
    @TheViral_fyp Před 3 měsíci

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

  • @atifayaz3495
    @atifayaz3495 Před 4 měsíci

    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

  • @VP-es6wy
    @VP-es6wy Před 10 měsíci

    Will you be posting regularly?

  • @user-ku6km4ou8q
    @user-ku6km4ou8q Před 10 měsíci +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  Před 10 měsíci +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 Před 10 měsíci

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

  • @abrarmasumabir3809
    @abrarmasumabir3809 Před 8 měsíci

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

  • @hassanali-il3rk
    @hassanali-il3rk Před 10 měsíci

    can i ask hint to hackerrank problem?

  • @lazyemperor5182
    @lazyemperor5182 Před 9 měsíci

    More videos please

  • @TheJohnniePlays
    @TheJohnniePlays Před 10 měsíci +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  Před 10 měsíci +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 czcams.com/video/UJrzgjblMCM/video.html

    • @TheJohnniePlays
      @TheJohnniePlays Před 10 měsíci +2

      @@Errichto This is it. Thank you.

  • @surajshekhar17
    @surajshekhar17 Před 7 měsíci

    ✨💫

  • @aisha9763
    @aisha9763 Před 7 měsíci

    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 Před 7 měsíci

      Good-hearted guys

    • @adib7143
      @adib7143 Před 5 měsíci

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

  • @IngCivil-vi9jr
    @IngCivil-vi9jr Před 12 dny

    more videoss please

  • @lazyemperor5182
    @lazyemperor5182 Před 8 měsíci

    More edu videos please

  • @stati5tik
    @stati5tik Před 4 měsíci

    first problem is basically what integral images are about.

  • @milanboroja7094
    @milanboroja7094 Před 10 měsíci +2

    Hi from Banja Luka

  • @SabarMohamed
    @SabarMohamed Před 10 měsíci +1

    It's been a while 😭

  • @adolft_official
    @adolft_official Před 8 měsíci

    I think erricto is the best programmer on earth without a *beard*

  • @richardharris202
    @richardharris202 Před 9 měsíci

    😶‍🌫️✨

  • @AsherDMckoy
    @AsherDMckoy Před 10 měsíci

    Do you still do tutoring?

    • @Errichto
      @Errichto  Před 10 měsíci

      I do. You can find my email id in the "About" section on CZcams.

  • @nightsusmare8468
    @nightsusmare8468 Před 6 měsíci +2

    polska gurom

  • @kartik4792
    @kartik4792 Před 10 měsíci +1

    3 views 13 likes!

  • @mirza5635
    @mirza5635 Před 10 měsíci

    Eat burger

  • @guszkiewiczkrzysztof4438
    @guszkiewiczkrzysztof4438 Před 3 měsíci

    dawaj tyeraz po polsku

  • @camperjett
    @camperjett Před 10 měsíci

    Can this comment get pinned?

  • @rimurusama5070
    @rimurusama5070 Před 10 měsíci

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