Count pairs with given sum | Array | Love Babbar DSA Sheet | Amazon🔥

Поделиться
HTML-код
  • Опубликовано: 16 янв 2025

Комментарии • 73

  • @fahadabdullah687
    @fahadabdullah687 2 года назад +5

    beautiful explanation....gfg explanation ise bhi bht acha aur easier ..great one bhai!

  • @satyamkumar6469
    @satyamkumar6469 2 года назад +2

    Great explanation ,till now I was just wondering that why we are doing sum -arr[i] but now it is all clear thanks alot!

  • @jk47nitk
    @jk47nitk 2 года назад

    simple, best and less taking time explanation video

  • @RonitSagar
    @RonitSagar 2 года назад

    bhaiya aap pentab kaun saa use krte ho...can you please mention the link in reply

  • @nehagunapooti2731
    @nehagunapooti2731 9 месяцев назад

    Forever grateful for you bhai, because of you I got my first job

  • @udaytewary3809
    @udaytewary3809 2 года назад +1

    Really thankyou bhaiya for such a easy explanation although i have not study map but your easy explanation made it easier for me to understand

  • @explorewithshobhit9157
    @explorewithshobhit9157 2 года назад

    Bhai boht badiya 👏🔥

  • @vivek4312
    @vivek4312 Год назад

    great explaination brother!

  • @amankhanoria2053
    @amankhanoria2053 3 года назад +2

    good work brother aapki wajah se data structure seekh paya mai

  • @vikalpjain1098
    @vikalpjain1098 2 года назад +4

    I tried by implementing this with input 1,1,1,-1,-1,-1 is giving 6 output, but actual output is 9.

    • @aeroabrar_31
      @aeroabrar_31 2 года назад +3

      Bhai constraints me saare elements positive de rakhe hai..
      This approach wont work for negatives i guess.

    • @toshanverma1084
      @toshanverma1084 Год назад

      sort then try this it will work

  • @Curiousss_Shivammm
    @Curiousss_Shivammm Год назад

    bhaiya agr iski jagah 2 pointer approach use krenge to kya tc jyada ho jayegi array ko sort krne ke chakkar mein

  • @mohammedyasser4717
    @mohammedyasser4717 2 года назад

    intuitive approach and good explanation ! thanks

  • @vaneelakhatri
    @vaneelakhatri 2 года назад +1

    Thanks for this solution 🙏🏻🙏🏻🙏🏻🙏🏻

  • @justin.j4440
    @justin.j4440 2 года назад +1

    Well explained mate!

  • @rohandevaki4349
    @rohandevaki4349 3 года назад +1

    what is unordered map ? at 3:11 ? is it on java also?

    • @bhargav4g538
      @bhargav4g538 3 года назад

      Bro try dictionary in java

    • @bhargav4g538
      @bhargav4g538 3 года назад +1

      Bro it’s just like dictionaries initially all are false ie zeros so frequencies are adding 2nd above return statement and they are counting inside if when they encounter use dict I use python same doubt came sorted with dict

    • @altafmazhar7762
      @altafmazhar7762 3 года назад +1

      tru hashmap in java

  • @maheshwarananbalagan9803
    @maheshwarananbalagan9803 Год назад

    Brute force algorithm not work sir

  • @kulyashdahiya2529
    @kulyashdahiya2529 Год назад

    Great one,
    For python use counter() which is a subclass of dict.

  • @nomaanahmad5851
    @nomaanahmad5851 3 года назад +3

    Bhaiya please isko jaldi poora krke dp ko kariye please

  • @pranaymishra4407
    @pranaymishra4407 3 года назад +2

    very clearly explained thanks bhai

  • @oqant0424
    @oqant0424 3 года назад +1

    nice explaination

  • @shaikbabasaheb9801
    @shaikbabasaheb9801 2 года назад

    Hello sir I am preparing for amazon interview. Can i use python language to code during interview.

  • @nehalpradhan2229
    @nehalpradhan2229 2 года назад

    6:00 why didn't you add 7 in map??

  • @abinayashrikbs6684
    @abinayashrikbs6684 Год назад

    you can talk in english throughout the video which will help who doesnt understand hindi.

  • @deeptimayeemaharana2448
    @deeptimayeemaharana2448 2 года назад

    map mein check karne se pehle ki element hai ya nahi, array ko toh map ke andar dala hi nahi...bhaiya samajh nahi aya

  • @mrinmoyhalder7293
    @mrinmoyhalder7293 2 года назад +2

    Interestingly, if it was to print all the pairs then using map also time complexity is O(n^2). because for every element in the given array we need to run a loop upto key_count stored in map. the worst case is [ 2,2,2,2] ans target is 4.

    • @adityacr7407
      @adityacr7407 Год назад

      Searching in an unordered map is O(1)

  • @AmanSharma-xq7gv
    @AmanSharma-xq7gv 2 года назад

    bhai ji ye mila na question ka ans gfg be text pdh ke to kuch samaj hi ni aa raha tha...Thanks

  • @AmitDas-hu3gr
    @AmitDas-hu3gr 3 года назад

    Bro love babbar DSA sheet ke baaki problems ke soultions ki video kab aayegi?

  • @pratikghule2995
    @pratikghule2995 3 года назад +1

    find number of pairs of 5 which can made with natural numbers

  • @dhruv2014
    @dhruv2014 2 года назад

    Nice explanation

  • @sohel4633
    @sohel4633 2 года назад

    Your DSA solution video is very helpful 🥰

  • @akashanand6531
    @akashanand6531 3 года назад +1

    awesome explanation

  • @yogeshgavali5238
    @yogeshgavali5238 3 года назад

    Greatly

  • @paullater6230
    @paullater6230 3 года назад

    Amazing explanation 👏 👌 👍

  • @manthan7535
    @manthan7535 2 года назад +1

    plz plz upload for jAVA also

    • @rickyarya7673
      @rickyarya7673 2 года назад

      // { Driver Code Starts
      //Initial Template for Java
      import java.io.*;
      import java.util.*;
      public class GFG {
      public static void main(String[] args) throws Exception {
      BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
      int tc = Integer.parseInt(br.readLine().trim());
      while (tc-- > 0) {
      String[] inputLine;
      inputLine = br.readLine().trim().split(" ");
      int n = Integer.parseInt(inputLine[0]);
      int k = Integer.parseInt(inputLine[1]);
      int[] arr = new int[n];
      inputLine = br.readLine().trim().split(" ");
      for (int i = 0; i < n; i++) {
      arr[i] = Integer.parseInt(inputLine[i]);
      }
      int ans = new Solution().getPairsCount(arr, n, k);
      System.out.println(ans);
      }
      }
      }
      // } Driver Code Ends
      //User function Template for Java
      class Solution {
      int getPairsCount(int[] arr, int n, int k) {
      // code here
      int count =0;
      HashMap mapValue = new HashMap();

      for(int i=0; i

  • @sanushgowdabr7217
    @sanushgowdabr7217 3 года назад +2

    Please Explain concepts in English

  • @M10-r8q7h
    @M10-r8q7h 2 года назад

    man this was easy prblm😑😑

  • @90krishika
    @90krishika 2 года назад

    Can somebody help me with this c# code? I am not able to get the expected result. Urgent please
    public static int FindMaxNumForMaxSum(int[] nums, int k)
    {
    int result = 0;
    int N = nums.Length;
    var map = new Dictionary();
    //[1, 5, 3, 3, 3],.. k = 6
    for (var i = 0; i < N; i++)
    {
    var complement = k = nums[i];
    if (map.ContainsKey(complement))
    {
    //we'll increase the map value at this key and assign to result
    result = map[complement] += 1;
    }
    else
    {
    map.Add(k - nums[i], nums[i]);
    }
    } //end of for loop
    return result;
    }

  • @rohandevaki4349
    @rohandevaki4349 3 года назад +3

    please write the code in java also

    • @rickyarya7673
      @rickyarya7673 2 года назад

      // { Driver Code Starts
      //Initial Template for Java
      import java.io.*;
      import java.util.*;
      public class GFG {
      public static void main(String[] args) throws Exception {
      BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
      int tc = Integer.parseInt(br.readLine().trim());
      while (tc-- > 0) {
      String[] inputLine;
      inputLine = br.readLine().trim().split(" ");
      int n = Integer.parseInt(inputLine[0]);
      int k = Integer.parseInt(inputLine[1]);
      int[] arr = new int[n];
      inputLine = br.readLine().trim().split(" ");
      for (int i = 0; i < n; i++) {
      arr[i] = Integer.parseInt(inputLine[i]);
      }
      int ans = new Solution().getPairsCount(arr, n, k);
      System.out.println(ans);
      }
      }
      }
      // } Driver Code Ends
      //User function Template for Java
      class Solution {
      int getPairsCount(int[] arr, int n, int k) {
      // code here
      int count =0;
      HashMap mapValue = new HashMap();

      for(int i=0; i

  • @Nick-and-Boys
    @Nick-and-Boys 2 года назад

    samjh nhi ayya bhai
    btw iam begginer

  • @ankitparashar8730
    @ankitparashar8730 3 года назад

    Only two pointers works when same type of intution ques on codeforces

  • @iremtaze6262
    @iremtaze6262 Год назад

    Why do you write the title in English even though you are speaking in Hindi? God, there are several videos like these I think I should learn Hindi

  • @mereRevyoos
    @mereRevyoos 3 года назад +2

    #include
    #include
    using namespace std;
    int main()
    {
    vector a={1,2,3,4};
    int size_a= a.size();
    vector answer;
    for(int i=0; i

    • @sudhakarsingh7613
      @sudhakarsingh7613 3 года назад +1

      bcoz answer is empty

    • @yourentertainer19
      @yourentertainer19 3 года назад +1

      r u kidding

    • @prayagrajwade8699
      @prayagrajwade8699 3 года назад

      Hope you got your answer why you are not getting the output

    • @mereRevyoos
      @mereRevyoos 3 года назад

      @@prayagrajwade8699 we have to use push_back or we have to specify the size of vector a(4)

    • @prayagrajwade8699
      @prayagrajwade8699 3 года назад

      @@mereRevyoos no need to specify size for the vector...you just have to push the elements in vector

  • @priyabratmail8936
    @priyabratmail8936 3 года назад

    Bhaiya ,I have just completed array in dsa.I could do this problem using loops but I don't know what is map . should I learn maps now or I should move ahead?

  • @shivammathur665
    @shivammathur665 11 месяцев назад

    Bhai saans tho le kam se kam..... Aise kya rurt k aaya tha kya??? 😂

  • @Anonymous-qf6jn
    @Anonymous-qf6jn Год назад

    bekar explanation kuch smhj ni aaya

  • @atulkumar-bb7vi
    @atulkumar-bb7vi 2 года назад

    Nice explaination

  • @maqboolmirzaan2660
    @maqboolmirzaan2660 2 года назад

    Good explanation

  • @fiza8266
    @fiza8266 11 месяцев назад

    nice explanation