Maths for DSA/CP : All You Need To Know

Sdílet
Vložit
  • čas přidán 16. 07. 2024
  • In this video, I tried to cover all of the things that are math related and are used in Competitive Programming till the Beginner and Intermediate Level.
    Maths in this video is enough for getting till the purple (candidate master) level.
    If you want to advance higher, you'll have to learn more things - like Probability and Expected Values, more Number Theory etc.
    Subscribe for more content.
    Chapters:
    00:00 - Introduction and Expectations
    01:50 - Part 1
    Number theory basics, Divisors, Multiples, Sieve, GCD, etc
    30:40 - Part 2
    Modulo Arithmetic, Binary Exponentiation, Division Under Mod
    59:00 - Part 3
    Basic Combinatorics, Counting Principles, How to find nCr%p

Komentáře • 211

  • @debjitdasgupta5502
    @debjitdasgupta5502 Před 2 lety +86

    Don't stop the DSA/CP series! Amazing video as usual!!

  • @harshpandey4190
    @harshpandey4190 Před 6 měsíci +9

    Best Video on number theory by Best of the Community

  • @sivasainagireddi7956
    @sivasainagireddi7956 Před 2 lety +16

    Exactly this is what I m searching for for.
    GREAT EXPLANATION

  • @shubhamchidrawar9477
    @shubhamchidrawar9477 Před 2 lety +5

    Awesome video!
    This is very high quality content, Eagerly waiting for the second part.

  • @girishbhargava6367
    @girishbhargava6367 Před 2 lety +3

    I really respect the people who add time stamps in their videos

  • @tirthasg
    @tirthasg Před 2 lety +10

    Your explanations are great. Well done!

  • @shresthjain985
    @shresthjain985 Před 2 lety +1

    Crisp and to the point content. Well Done.

  • @ANILKUMAR-mi5xm
    @ANILKUMAR-mi5xm Před 2 lety +4

    Wow! Modulo inverse and Fermat theorem Explanation I will never forget, ❤❤❤❤.

  • @saurabhkumarchoudhary1795

    This is the thing I was waiting from past 4 years

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

    thanks for explaining modulo arithmetic in full details !!! great work

  • @himanshu010
    @himanshu010 Před 2 lety +1

    Gread content Grandmaster. Keep uploading. 🤝

  • @yashrajadmane
    @yashrajadmane Před 2 lety +10

    Not all heroes wear capes.. Some make DSA videos on YT.
    Thanks brother 🙌

  • @parthsalat
    @parthsalat Před 2 lety +1

    Amazing content, as usual!

  • @aayushverma5121
    @aayushverma5121 Před 2 lety +5

    Just the content I was looking for !
    Thank you for the video

  • @Entertainment15683
    @Entertainment15683 Před 2 lety +3

    Oh finally you are back 😊 :))) much more love to you bhaiya

  • @AkhileshSingh-wq6gt
    @AkhileshSingh-wq6gt Před 2 lety +1

    Thank you Bhaiya...
    Modular Arithmetic part taught me something new.. 😊

  • @jayantgupta5310
    @jayantgupta5310 Před 2 lety

    Literally bhaiya I was finding this type of video for 2-3 days and nothing got quality content like this
    Thanks a lot
    Aapne meri sun li

  • @surajkumar-ze5jl
    @surajkumar-ze5jl Před 2 lety +4

    I am in mid of CP course of coding ninja and I recently going with topic of number theory and almost mujhay meri kashti dubti nazar aarahi this but is video ne meri kasti sambhal li modulo arithmetic part is awesome for me thank you Utkarsh bhaiya.

  • @harshit_gajera
    @harshit_gajera Před rokem +8

    At 45:50, if b==0, you should return 1; this code gives the wrong answer in some test cases. ex= 9 1 7
    Thank you.
    Waiting for the next video.

  • @Manish_Upadhyay
    @Manish_Upadhyay Před 2 lety +4

    You are inspiration for me ❤️✨

  • @abhishekkeshri3974
    @abhishekkeshri3974 Před 2 lety +1

    Thanks for this. It really helps me a lot .

  • @AviralDewan
    @AviralDewan Před 2 lety +87

    Bro please make a video on dynamic programming

  • @Profnegi
    @Profnegi Před 6 měsíci

    Today i start cp and learning from grandmaster directly.. like wow this is amazing! Lot of resp++

  • @SunilKumarGvBLC
    @SunilKumarGvBLC Před 2 lety +10

    In 24:03, while explaining sieve of eratosthenes, the upper for loop should go from 2 to i * i

    • @utkarshgupta9858
      @utkarshgupta9858  Před 2 lety +7

      The time complexity is still the same...
      Plus my template also stores all of the primes in a vector, so that's why i < N

    • @SunilKumarGvBLC
      @SunilKumarGvBLC Před 2 lety +2

      Got it brother! Thanks for your instant reply!

    • @sachinupreti7159
      @sachinupreti7159 Před 2 lety +1

      @@utkarshgupta9858 sun yr, bit manipulation pe bhi sikha de kuxh...

    • @justworkfine321
      @justworkfine321 Před 2 lety

      So you mean constant not matter I*i we get const value and for big o for worst case we can't consider constant so it's complexity O(n) times

    • @shantivaranasi231
      @shantivaranasi231 Před 2 lety

      @@utkarshgupta9858 can u share related problems of these topics

  • @rajukachori9536
    @rajukachori9536 Před 2 lety +5

    SIR UR DOING GREAT JOB FOR US ...THANKU PLEASE MAKE MORE THIS VIDEOS .WE GET TO LEARN MANY THINGS FROM IT

  • @theresweet984
    @theresweet984 Před 2 lety +7

    Hola, Utkarsh Gupta!
    Please keep it up this kind of competitive edu series. Thanks!

  • @vtechrepo1927
    @vtechrepo1927 Před 2 lety +1

    after so long
    wating for this video

  • @sandeepsharma2183
    @sandeepsharma2183 Před 2 lety

    Most awaited video♥️♥️

  • @vivekdhir77
    @vivekdhir77 Před 2 lety +2

    Nice, bro long time no see. I was waiting.....

  • @pksk7952
    @pksk7952 Před 2 lety +52

    please make more videos please increase the frequency as this is kind of content we want!

  • @allmighty2000
    @allmighty2000 Před 2 lety

    the nlogn proof was amazing

  • @apoorvamittal4112
    @apoorvamittal4112 Před 2 lety +7

    just the person I was looking for, thanks 🙌

  • @PrinceKumar-uz9xv
    @PrinceKumar-uz9xv Před 2 lety

    thanks, ❤ bhaiya I wanted this type of video.

  • @jitendrakhanna4426
    @jitendrakhanna4426 Před 2 lety +38

    From where you learn all these things or just while practicing you learn..

  • @DeepakKumar-mn7sp
    @DeepakKumar-mn7sp Před 2 lety +3

    How to setup sublime like that in 5:30 , the TC part ?

  • @wondol4486
    @wondol4486 Před 2 lety +1

    This is perfect lecture

  • @ANANDKUMAR-jk9yp
    @ANANDKUMAR-jk9yp Před 2 lety +26

    By the way, time complexity of gcd is log(min(a,b)).

  • @dhananjaysharma4379
    @dhananjaysharma4379 Před 2 lety +2

    very nice explanation, just adding the practice questions related to the concepts would be even better.

  • @notlinuxneverdies5846
    @notlinuxneverdies5846 Před 2 lety +1

    Thank you sooo much!!!

  • @anupamdubey5736
    @anupamdubey5736 Před 2 lety

    Awesome class!

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

    thank you very much! very helpfull!

  • @ananyasuryavanshi2800
    @ananyasuryavanshi2800 Před 2 lety +3

    Please make one whole video explaining time-complexity also.

  • @tessabloomx8660
    @tessabloomx8660 Před 2 lety +5

    hey in your binary exponentiation (pw) function, in the base case if b is 0 then we should return 1 as a^b will become 1 and m is assumed to be greater than 1.

  • @murtazamister8125
    @murtazamister8125 Před 2 lety +1

    Modular division at 55:35 for these two cases are not returning equal output,
    a=48521 b=654 m=17
    output : 6 11
    a=48521 b=654 m=13
    output : 9 11
    Is it only happening with me? or they do produce different output?

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

    Really liked your explanations and proofs for n/1, n/2 , n/3, ....n/n = logn
    Intuition why sieve inner loop starts at i*i and the way you improved the complexity o(n), o(sqrt(n)), for queries o(n*loglogn)
    Intuition of mod operations ( +, -, *, /) and why / wont work like other.
    o(1) calculation of inverse m! ( it looked obvious after you explained XD ) m/m! -> 1/(m-1)!

  • @chatrughanprasad7778
    @chatrughanprasad7778 Před 2 lety

    Great Lecture Bro!

  • @harshshah9319
    @harshshah9319 Před 2 lety

    this helps a ton !!

  • @DeepakKumar-mn7sp
    @DeepakKumar-mn7sp Před 2 lety +1

    At 23:55 that sieve template, how the whole template code arrives just by typing sieve?

  • @yashkhatwani3198
    @yashkhatwani3198 Před 2 lety

    Hi Utkarsh how are you getting all that , test , run ,edit , time and stop feature in your editors output

  • @abhinavkumar5298
    @abhinavkumar5298 Před rokem

    Amazing Video.

  • @vanquishersgaming138
    @vanquishersgaming138 Před 2 lety

    You're awesome 🙌

  • @shubh4096
    @shubh4096 Před 2 lety

    how did you change your codeforces cp handle from healthyUG to demoralizer??? i just wrote without thinking much at that time now i want to change it! how to do it can you tell me plz!

  • @lakeshkumar1281
    @lakeshkumar1281 Před 2 lety

    simply awesome

  • @sunnykumarsingh7039
    @sunnykumarsingh7039 Před 2 lety

    in the mod program, if b==0 we should return 1 or a%m?

  • @random_memes009
    @random_memes009 Před 2 lety +1

    Hwy, plz make video on time complexity. Thk yu for helping us

  • @BRAJESHKUMAR-lz4mw
    @BRAJESHKUMAR-lz4mw Před 2 lety

    Is it possible to right a number in form of 3^x + 7^y where x and y is any positive integer value.
    We need to return true or false.
    Can someone please provide a efficient solution for this question?

  • @codeblooded6760
    @codeblooded6760 Před 2 lety +51

    Hey recently saw your mock interview with kerthi purswani in which you mentioned that hard ques will most probably be not asked in google interviews. Can you make a detailed video about the difficulty level of ques that can be asked in google interviews with examples of some questions so we can get a good idea about the level of ques asked. Also if you could compare them with respect to leetcode medium and hard questions that would be very helpful. Thanks in advance!

  • @realnight_bot2536
    @realnight_bot2536 Před 2 lety

    Are JOD sir 🤩

  • @Advebtures-hx4hv
    @Advebtures-hx4hv Před 2 lety +1

    Please make a video for greedy it is very helpful

  • @KunalLadhani
    @KunalLadhani Před 2 lety

    How did you setup sublime for CP
    Can you tell pls.

  • @pronoob5664
    @pronoob5664 Před 2 lety +1

    Thank you LORD DEMORALIZER

  • @tejaswarade3785
    @tejaswarade3785 Před 2 lety +1

    can you please give practice problems on Maths part in DSA

  • @arnabchakraborty246
    @arnabchakraborty246 Před 2 lety

    Grt video. Please share some problem set to practice

  • @saranggakhar7932
    @saranggakhar7932 Před 2 lety

    Which software did you use for drawing??

  • @rishav144
    @rishav144 Před 2 lety +2

    kindly continue with Graph series

  • @joshikroshan5584
    @joshikroshan5584 Před 2 lety

    After so long.... finally..😌

  • @codenchill732
    @codenchill732 Před 2 lety +44

    Please make a video on bit manipulation. Especially on XOR operation

    • @yath3681
      @yath3681 Před 2 lety +2

      yes , please !
      everything about bitwise operator questions in CP

  • @crazyteam9370
    @crazyteam9370 Před 2 lety

    Hello brother ! Please make a video on how to setup Sublime text as you had in your laptop

  • @cypher7536
    @cypher7536 Před 2 lety +1

    Bro please tell how to make sublime like yours

  • @GautamSharma-vt9yr
    @GautamSharma-vt9yr Před 2 lety

    Bhaiya can you please attach some practice problems and relevant further reading material on this?
    Thanks

  • @rohitjangir8303
    @rohitjangir8303 Před 2 lety

    Hey brother can u make a video on how to setup sublime text like you for competitive programming

  • @Ram-uf8mv
    @Ram-uf8mv Před 2 lety +4

    in pw(a, b, m), when b is 0, why are you returning a % m? it should always be 1 right?

    • @utkarshgupta9858
      @utkarshgupta9858  Před 2 lety +5

      Oh right yeah... I think I mistyped that part... And the tests didn't fail🤦🏻‍♂️
      I hope learners don't get confused. Thanks for pointing out

  • @sahilanand30
    @sahilanand30 Před 2 lety +1

    Nice explanation

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

    if you prefer a textbook, consider the competitive programmers handbook :)

  • @ascyrax8507
    @ascyrax8507 Před 2 lety +1

    I used to dread Modular multiplicative inverse. Not anymore 😌

  • @PK-mx3tv
    @PK-mx3tv Před 2 lety

    thank you legenD !!!!!

  • @aryankumar87771
    @aryankumar87771 Před rokem +2

    for prime approach would this be not much faster ?
    bool isPrime(int N) {
    if(N==1){
    return false;
    }
    int count = 0;
    for(int i = 1; i*i

    • @ritvikreddy3959
      @ritvikreddy3959 Před 11 měsíci

      removing the nested if won't reduce the time complexity it will still be O(root(n))

  • @RahulSingh-nf3dr
    @RahulSingh-nf3dr Před rokem +1

    27:50
    time complexity should be O(log(min(a,b)))
    correct me if I am wrong

  • @rahul_singh_rajput3292
    @rahul_singh_rajput3292 Před 2 lety +1

    Bhaiya plS make video on how to Start for CP.. How should we learn Dsa correcr way

  • @tiyas1915
    @tiyas1915 Před rokem

    Thanks!!

  • @prazzwalanand8162
    @prazzwalanand8162 Před 2 lety

    Thanks 👍

  • @ddnsdeepak8148
    @ddnsdeepak8148 Před 2 lety

    Bro please make a video on your sublime text setup of U .

  • @TilakRaj-qo6ic
    @TilakRaj-qo6ic Před měsícem

    Can someone please tell me which software he used to create thie presentation please

  • @muthupandideivamsanmugam1774

    I have one doubt if we multiply a number it gets overflow and if we add also it gets overflow but if we divide a number how it will get overflow

  • @ffera6611
    @ffera6611 Před rokem

    thanks for video bro

  • @abhishekkumar-vk8kc
    @abhishekkumar-vk8kc Před 2 lety

    Sir please make video on dp and graphs from basic to advanced

  • @thilakreddy1904
    @thilakreddy1904 Před 2 lety

    can u explain what is O(log)

  • @AjithKumaR-jw9wt
    @AjithKumaR-jw9wt Před 2 lety

    Bro before cp what are the topics we want to cover in dsa

  • @AshishGusain17
    @AshishGusain17 Před 2 lety +2

    42:21 shouldn't base case return 1

  • @MdMaruf-ln9pv
    @MdMaruf-ln9pv Před 7 měsíci

    sir can you please tell me from where you learned all this topics??

  • @samanwaybarman3316
    @samanwaybarman3316 Před 2 lety

    Searching and sorting and precomputation

  • @manayyadav4911
    @manayyadav4911 Před 2 lety +18

    Hey, could you please make a video on how to setup sublime text for cp on windows. It's really frustating for windows peeps to execute and run programs.

    • @humanbeing6042
      @humanbeing6042 Před 2 lety

      Checkout Luv competitive programing course playlist.The second video completely about setup Link: czcams.com/video/Zlx7gmt3lBU/video.html

    • @manayyadav4911
      @manayyadav4911 Před 2 lety

      @@humanbeing6042 I have already seen it. But not able to setup from his way. I am not able to make my custom build file and stuck forever :(

    • @johntony366
      @johntony366 Před 2 lety

      You can use WSL to get the linux experience on windows

  • @nothingtolose682
    @nothingtolose682 Před 2 lety

    bhaiya please make a video on dynamic programming

  • @GeneralistDev
    @GeneralistDev Před 2 lety

    Please share your sublime setup

  • @simranvedpathak7112
    @simranvedpathak7112 Před 2 lety +2

    🔥🔥

  • @Aditya-if3ij
    @Aditya-if3ij Před 2 lety

    Purple is my aim for this year.

  • @aranasrehman106
    @aranasrehman106 Před 2 lety

    Could you please add captions (English Subtitle) Here????

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

    Thank u

  • @sherlockjunior8612
    @sherlockjunior8612 Před 11 měsíci +3

    Prime or not Prime
    Number of divisors of each number from 1 to N
    Sieve of Erastothenes
    GCD
    Modular Aritihmetic (
    Add,
    Subtract,
    Multiply,
    Pow(Binary Exponentiation),
    Fermat's Little Theorem to get (1/a)%M we get pow(a,M-2)%M where M is prime number divisor,
    )
    Combinatronics: nCr calculation in linear time using fact and inv_fact array (Usually paired with %M problems)

  • @41kaushalchauhan
    @41kaushalchauhan Před 2 lety

    tqtq for thisone ❤️