Must Do Sieve Questions | Easy Medium | CP Course | EP 63

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

КОМЕНТАРІ • 44

  • @harshitsingh4764
    @harshitsingh4764 3 роки тому +20

    Didn't know we can use sieve in such ways 😲, very informative video 🙇‍♂️

  • @dibyajyotimahuri4891
    @dibyajyotimahuri4891 3 роки тому +10

    Best cp course on UA-cam ❤

  • @omkarshendge5438
    @omkarshendge5438 3 роки тому +6

    If this is a easy-medium question then i don't know what a hard question will look like!😲😲

  • @aryashreyas4263
    @aryashreyas4263 2 роки тому +2

    multiples_ct[i] += hash[j]; // this logic is just wow!

  • @ishanjoshi1816
    @ishanjoshi1816 2 роки тому +1

    Hats off to the way you solved the problem...

  • @madhurgupta3849
    @madhurgupta3849 3 роки тому +2

    Growing faster 💪💪💪

  • @surjeetsingh433
    @surjeetsingh433 3 роки тому +4

    Number divisible by p+number divisible by q+number divisible by lcm(p+q).

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

    time complexity will still be N^2, right? could it have been done by simply checking divisibility of numbers till N for numbers in array?

  • @shrutiagrawal6626
    @shrutiagrawal6626 3 роки тому

    uh r the best bro..

  • @shoryasinghal5241
    @shoryasinghal5241 2 роки тому +1

    took me a while to understand but got it.

  • @chiraggoyal9646
    @chiraggoyal9646 2 роки тому

    Thanks bhaiya

  • @sonalisingh2834
    @sonalisingh2834 3 роки тому

    Thanks 😊

  • @funenjoynilaypatel4553
    @funenjoynilaypatel4553 2 роки тому +1

    27 march 2022 4:45 pm

  • @malkeetsapien4852
    @malkeetsapien4852 2 роки тому +1

    bro Y R U not uploading videos !?? we all R dead waiting for ur videos...

  • @veerusingh1981
    @veerusingh1981 3 роки тому

    Loved it bhiya

  • @ankithreddyadudodla7673
    @ankithreddyadudodla7673 3 роки тому

    Thank you

  • @Krishna-nc3fq
    @Krishna-nc3fq Рік тому

    You declared 'q' twice in your code, both on the 21st line and the 24th line. Can anyone please explain why didn't it receive a compilation error for this redeclaration?

  • @udaymishra5916
    @udaymishra5916 3 роки тому

    Please tell me that how do determine the complexity here in first in which you say that t must run under logn or 1 to run the algo of this question ⁉️???

    • @iamluv
      @iamluv  3 роки тому +1

      check the sieve tutorial video i have explained sieve related time complexity there

    • @udaymishra5916
      @udaymishra5916 3 роки тому

      @@iamluv okk

  • @vipinrawat21
    @vipinrawat21 3 роки тому

    Bhaiya koi index type ka bhi de do kis time pe konsa topic karaoge schedule type ka khuchh

  • @shafahidrahman8333
    @shafahidrahman8333 3 роки тому +1

    Bro will you cover bitwise sieve in your course?

  • @innocentboy5546
    @innocentboy5546 3 роки тому

    Sir code kis app par karte hai

  • @algotalk5368
    @algotalk5368 3 роки тому

    Great

  • @prashantMishra-it2im
    @prashantMishra-it2im 3 роки тому

    Please make a video on oops in c++

  • @Rekha-j2g
    @Rekha-j2g 5 місяців тому

    nice

  • @yemantech8398
    @yemantech8398 3 роки тому +2

    Hello love sir

  • @Girish415
    @Girish415 3 роки тому

    Cool

  • @aligohar1708
    @aligohar1708 3 роки тому +3

    What if you just put all the values in a set and then returned its value.....

  • @badalwanjari4964
    @badalwanjari4964 2 роки тому

    🙌🙌🙌👏

  • @monitomar9653
    @monitomar9653 3 роки тому

    Harsh Sharma User C Nesting

  • @pradyumnSharma45
    @pradyumnSharma45 3 роки тому

    Bro please upload full course in data structures

  • @p38_amankuldeep75
    @p38_amankuldeep75 2 роки тому

    💛🧡❤🧡💛

  • @crazyboy-gw7rk
    @crazyboy-gw7rk 2 роки тому

    Can anyone tell how complexity of seive loop is not n^2 please??🙂

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

      outer loop runs n time and inner loop for a particular number i it runs n/I times so ,basically for 1 inner loop runs n/1,for 2 it is n/2 ...for I it is n/I so on...for n its n/n..hence total no of iterations would be n/1 + n/2 + n/3 + ...+ n/n = nlogn(you can checkout on the internet that how this sum is nlogn)..Hence tc would be O(nlogn)..

  • @Jabbal-Tent-House
    @Jabbal-Tent-House 3 роки тому

    sir stl ke questions dedo sir and pls make a video on hashmap🙏

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

    Can anyone tell me what's the problem with this code?
    Six test cases are not passing?
    #include
    using namespace std;
    const int N = 2e5 + 10;
    int hsh[N];
    int cnt[N];
    int main() {
    int n;
    cin >> n ;
    for(int i=0; i> x;
    hsh[x]++;
    }
    for(int i = 1; i < N; ++i){
    for(int j = i; j < N; j += i){
    cnt[i] += hsh[j];
    }
    }
    int t;
    cin >> t;
    while(t--){
    int p,q;
    cin >> p >> q;
    long long lcm = (p * q * 1LL) / __gcd(p,q);
    long long ans = cnt[p] + cnt[q];
    if(lcm < N){
    ans -= cnt[lcm];
    }
    cout

  • @AudiRaistar
    @AudiRaistar 3 роки тому

    Hello sir

  • @yemantech8398
    @yemantech8398 3 роки тому +1

    I am first

  • @hattydeny985
    @hattydeny985 3 роки тому

    2dj0y
    #vur.fyi

  • @niteshchoubey3415
    @niteshchoubey3415 2 роки тому +1

    have written same code but my code is failing at case 5,6,7,12,13,14 error is runtime error
    please have a look at my code and tell problem
    #include
    #include
    using namespace std;
    const int Nmax = 2e5 + 10;
    int mp[Nmax];
    int total_multiple_present[Nmax];
    int main()
    {
    // takin count of element present in array
    int N;
    cin >> N;
    for (int i = 0; i < N; i++)
    {
    int ele;
    cin >> ele;
    mp[ele]++;
    }
    //makin total_multiple arry
    //as every element will be divisible by 1
    for (int i = 1; i < Nmax; i++)
    {
    for (int j = i; j < Nmax; j += i)
    {
    total_multiple_present[i] += mp[j];
    }
    }
    //takin no of queries
    int t;
    cin >> t;
    //for (auto it : total_multiple_present) cout p >> q;
    // lcm can overflow int range so use long long
    long long lcm = (p * q) * 1LL / __gcd(p, q);
    // total no in array divisible by p,q or pqboth will be no(p)+no(q)-no(lcm_of_P_q)
    long ans = total_multiple_present[p] + total_multiple_present[q];
    if (lcm < Nmax) ans -= total_multiple_present[lcm]; //
    cout

    • @VivekSharma-qw5ky
      @VivekSharma-qw5ky 2 роки тому

      (p * 1LL * q) : write in this way, p*q*1LL is same as p*q
      or use both long long