Array Subset of another array 🔥| Brute + Better + Optimal | Array | Love Babbar DSA Sheet | Hindi

Sdílet
Vložit
  • čas přidán 27. 07. 2024
  • Time Stamps :
    Problem discussion : 0:00
    Different approaches : 01:40
    Approach 1 (Brute Force) : 02:21
    Approach 2 (Sorting + Binary Search) : 05:00
    Approach 3 (Hashmap) : 06:55
    Code explanation : 09:15
    Time Complexity : O(n + m)
    Space Complexity : O(n)
    Problem Link : practice.geeksforgeeks.org/pr...
    C++ Code Link : github.com/Ayu-99/Love-Babbar...
    Python Code Link: github.com/Ayu-99/Love-Babbar...
    Love Babbar DSA Sheet : drive.google.com/file/d/1FMdN...
    Please like, share and subscribe if you found the video useful. Feel free to ask in comments section if you have any doubts. :)
    #DataStructuresAndAlgorithms
    #LoveBabbarDSASheet
    #interviewpreparation
    Array Subset of another array solution
    Array Subset of another array Leetcode
    Array Subset of another array C++
    Array Subset of another array C++ Hindi
    Array Subset of another array Hindi
    Checkout the series: 🔥🔥🔥
    👉 Array: • Arrays
    👉 Recursion : • Recursion
    👉 Stack and Queue : • Stack And Queue
    👉 Greedy : • Greedy
    👉 Dynamic Programming : • Dynamic Programming
    👉 Leetcode contests : • Leetcode contests
    👉 Leetcode June Challenge : • Leetcode June Challenge
    👉 Leetcode July Challenge : • Leetcode July Challenge
    LIKE | SHARE | SUBSCRIBE 🔥🔥😊

Komentáře • 31

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

    string isSubset(int a1[], int a2[], int n, int m) {
    //create empty map
    unordered_map map;
    //dump all a1 elements inside map and give each a count of 1
    for(int i=0;i

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

    Thanks for the timestamp. :)

  • @devansh462
    @devansh462 Před 2 lety

    Thank you so much for posting video keep making such a helpfull video 👌😊

  • @Romanticlovekdrama
    @Romanticlovekdrama Před rokem +1

    In Gfg not accepted mam

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

    Great sharing
    New friends

  • @OatsAurCode
    @OatsAurCode Před rokem

    Your videos are just awesome.
    Just sharing a another version of the code as the solution you showed in the video is somehow not passing all the test cases
    def isSubset(a1, a2, n, m):
    l1 = []
    check = True
    for i in a2:
    if not check:
    break
    else:
    if i in a1:
    check = True
    a1.remove(i)
    else:
    check = False
    if check:
    return "Yes"
    else:
    return "No"

  • @abhijeetgorai65
    @abhijeetgorai65 Před 2 měsíci

    am i only getting error while submitting test case no 51 /209

  • @jeevankumar.v5018
    @jeevankumar.v5018 Před 2 lety

    Thank you 👍

  • @animeExplainers
    @animeExplainers Před rokem +1

    mam please explain all approaches code solutions also

  • @RajnishKumar-sg8wi
    @RajnishKumar-sg8wi Před 2 lety

    Nice video

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

    Sister I request you to make an video on stl time complexities

  • @nikitasarda7389
    @nikitasarda7389 Před 2 lety

    Instead of hashmap, can we use hashset? Cz by default u r assigning 1 count for all the keys.

  • @jivanninawe3190
    @jivanninawe3190 Před 2 lety

    Mam recursion bano na hindhi playlist may 😁😁

  • @abhishekshrivastava8390

    In the second approach sorting time complexity of array will also be added.

  • @gamingclub5816
    @gamingclub5816 Před rokem

    Mam can yu please make a series related to hash map

  • @mayankjoshi8888
    @mayankjoshi8888 Před 2 lety

    💯💯

  • @user-gq1ij
    @user-gq1ij Před 2 lety

    Second approach Ki complexity nlogn hogi mlogn nhi, kyoki sorting krne me nlogn lag jayega

  • @ShivamYadav-lz5gx
    @ShivamYadav-lz5gx Před 2 lety

    Didi apne Bina array ke elements ka input liye hi kaise proceed Kiya code me

  • @ecs185_shaileshbharti3

    👌👍

  • @aakashvishwakarma4653
    @aakashvishwakarma4653 Před 2 lety

    💯💯💯😁

  • @rohandevaki4349
    @rohandevaki4349 Před 2 lety

    we can do in this approach also,
    we take two pointers, one i=0 on a1, and another j=0 on a2, then we iterate i until we reach a1s end
    and while iterating we check if j==m, if j==m , break and return yes, else check if a1[i]==a2[j] ,if equal j++;i++ , else only i++
    if j==m , return true, else return false.
    this approach takes only O(n) , it passed all the test cases for me, let me know if this is the optimised solution.
    BTW i liked your binary and hashmap approaches, didnt expect that, thanks.

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

    Pls Say Me Is Cp Necessary??

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

      If you are having problem understanding the problem and thinking of approach in online tests or contests, then yes cp is necessary

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

      @@AyushiSharmaDSA thanks

  • @ashishmishra-kp5zh
    @ashishmishra-kp5zh Před 2 lety

    this code will give error if the size of a2 is greater than a1

  • @AMANSAINI-qq7pm
    @AMANSAINI-qq7pm Před 2 lety

    string isSubset(int a1[], int a2[], int n, int m) {
    sort(a1,a1+n);
    sort(a2,a2+m);
    int count = 0 ;
    int k=0;
    for(int i=0;i

    • @psychology1649
      @psychology1649 Před 2 lety

      Why are using count .simply use one variable k only comparison the m ..and get the results

    • @justworkfine321
      @justworkfine321 Před rokem

      Suppose you sort both a and b
      Like and you sort both
      So
      Your a= 1 2 3 4
      Your b= 1 2 4
      Because your also not going to increase ot reach 4