Leetcode 1. Two Sum [3 approaches]

Sdílet
Vložit
  • čas přidán 10. 02. 2021
  • Leetcode 1. Two Sum
    leetcode.com/problems/two-sum/
    My contact details
    Instagram :- / frazmohammad
    Connect with me on LinkedIn :- / mohammad-f-bb4886157
    Telegram Group t.me/LeadCoding
    FREE INTERVIEW PREPARATION SERIES • Free Interview Prepara...
    You can practice for coding interview from here
    Leetcode Hard :- • Hard
    Leetcode Medium :- • Medium
    Leetcode Easy :- • Easy
    I am Mohammad Fraz , a final year Engineer at DTU and I create content for Coding and technical interviews for FAANG. I explain the intuition to solve Data Structure and Algorithm Questions from leetcode and other platforms. I also cover interview experiences for FAANG and other tech giants. You will also find lectures on the frequently asked interview questions.

Komentáře • 68

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

    Thank You Sir for this awesome and genuine content.
    This q looked difficult to me before but now its a piece of cake for me.
    All thanks to you Sir, May GBU with lots of love long life success happiness and enjoyment
    Thanks a lot again

  • @rickishere1492
    @rickishere1492 Před 2 lety

    much detailed solution ❤️🙏

  • @anushreevirtualgaming226

    for the same 1st brute force I got :
    Runtime: 416 ms, faster than 35.24% of C++ online submissions for Two Sum.
    Memory Usage: 10.3 MB, less than 75.73% of C++ online submissions for Two Sum.
    So , never get disappointed (it is heavily dependant on server response+ interenet connectivity)

  • @RAMANKUMARGCEBIT
    @RAMANKUMARGCEBIT Před rokem

    very helpful. deeply geateful.

  • @VivekKumar-ru8ur
    @VivekKumar-ru8ur Před 2 lety

    Line 6: Char 18: error: too few template arguments for class template 'pair'
    vector v;
    ^
    /usr/bin/../lib/gcc/x86_64-linux-gnu/9/../../../../include/c++/9/bits/stl_iterator.h:1286:12: note: template is declared here
    struct pair;
    ^
    this error getting using PAIR

  • @harshtyagi895
    @harshtyagi895 Před 3 lety +3

    at 2:07 I think indices 1,8 can also be the answer

  • @992_anisharoy9
    @992_anisharoy9 Před 2 lety +1

    Please share the previous video links

  • @prateekmahajan8680
    @prateekmahajan8680 Před rokem

    Hey Fraz,
    What tools you used to draw on MS Notebook, hardware specs please!

  • @kunalkoyande1963
    @kunalkoyande1963 Před rokem +5

    Great explanation Sir......Thank you for the video
    At 1:20 you told in the video that watch the previous video...
    Please give a link to the previous video of tools and everything else to solve the problems

  • @bbaig1821
    @bbaig1821 Před 3 lety +1

    Is .first and .second is predefined?? for number and index line number 12,13??

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

    Great explanation sir 🙏🙏🙏

    • @mohammadfraz
      @mohammadfraz  Před 2 lety

      Thanks 😊

    • @tejeshch
      @tejeshch Před 2 lety

      @@mohammadfraz sir could you please make a detailed video to find time and space complexity for beginners. I can code but cannot calculate sir. please. Thanks in advance;

  • @pratiyushkejriwal5736
    @pratiyushkejriwal5736 Před rokem +1

    which previous videos you are talking about here....I tried to find but I couldn't

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

    Fraz Sir I am new to the channel I couldn't find the previous video for this in which u have explained about the stl used for this so could u please help provide me the video links of the previous videos

  • @payalshorts6217
    @payalshorts6217 Před rokem

    U are god bro aapke videos motivate to krte hee hai

    • @payalshorts6217
      @payalshorts6217 Před rokem

      Saath saath understanding skills ko increase karne me help bhi krte hai

  • @riyagusain3439
    @riyagusain3439 Před rokem

    in case of Maps why we are using m.end() ? why we are comparing it to the end element of map?

  • @walkwithmanish
    @walkwithmanish Před 2 lety

    Fraz i loved this video but i wish to write solution in python since i am new to python i am not able to replicate what you did in java
    how can i get some python videos

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

    My o(n) approach -> in for loop, create a string and keep inserting the current index value if it doesnt exists in the string created so far. Thats it.
    For explaination, you can DM me

  • @NehaSharma-kx6hg
    @NehaSharma-kx6hg Před 2 lety

    BESTTTTTTTTT

  • @anushkathakur6531
    @anushkathakur6531 Před rokem

    can somebody please share the link of the previous video he is mentioning about in this video about the approaches?

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

    can you provide the solution in java of approach 2 and 3

  • @jatingupta3443
    @jatingupta3443 Před 2 lety

    cout

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

    pls provide the java code as well sir

  • @guptaji2989
    @guptaji2989 Před 3 lety

    Sir time complexity of find function is O(logN)

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

    Great explanation 🙏

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

    Sir which previous video you are talking here..i couldn't find that video

  • @KanisFatemaShanta
    @KanisFatemaShanta Před rokem +1

    2nd approach :
    if(m.find(y) != m.end())
    return (i , m[y])
    m[nums[i]] =i;
    vaiya please explain it.

  • @rekhasharma30
    @rekhasharma30 Před rokem

    which language you are using in the youtube ( C / C++ / Python) video? Difficult to understand it.

  • @mgfactors3510
    @mgfactors3510 Před rokem

    19:54 thanks bhaiya

  • @soumyadipsamanta3771
    @soumyadipsamanta3771 Před 3 lety +3

    What is the use of the line v.push_back()?

    • @giit85
      @giit85 Před 2 lety

      Its insert elements in vector

  • @dheerajkumarbaghel9983

    if anyone person not understand the CPP language and he use the other language then what have to do in this case

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

    Anyone tell me which previous video sir talking

  • @faizanahmad7227
    @faizanahmad7227 Před měsícem

    bhai i have written the same code that u have write at time 13:54 but it give the error for the value [3,2,3] for t =6 plz reply

  • @HimanshuSharma-oq3xg
    @HimanshuSharma-oq3xg Před rokem

    where can we find the lecture which we should watch before watching this video

  • @BcomingHIM
    @BcomingHIM Před rokem

    in interview, if I am able to give the first and second approach and not the third one...is it fine? or do we need to know all the approaches to a problem ?

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

      Depends on the interview level.

  • @karthikmamidishetti2528
    @karthikmamidishetti2528 Před 3 lety +4

    previous vidio link ??

  • @RahulKumar-xl3dd
    @RahulKumar-xl3dd Před rokem

    What is first and second over here, can any one please clarify this ???

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

    Why these CZcamsr prefer c++ instead of java

  • @akhileshgoel339
    @akhileshgoel339 Před rokem

    sir not able to understand approach 2

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

    I don't understand why no one does this in JavaScript.

  • @theyashsisodiya
    @theyashsisodiya Před rokem

    Any here who can help me ( i can able go code but I don't understand questions) What's the solution for that !?

  • @coderecipeofficial
    @coderecipeofficial Před rokem

    On a funnier note,
    Leetcode 1: Where dreams start
    .
    .
    .
    Leetcode 2: Where it ends...
    Story of most coders on leetcode 🤭

  • @shikhargupta1499
    @shikhargupta1499 Před rokem

    2nd approach wont work, in case the target is 10, it will return [8,8]

  • @coderecipeofficial
    @coderecipeofficial Před rokem

    Looking for the fastest two sum solution? We have explained the two sum problem in a very simple, step by step and easy to understand way. Do checkout our videos 🙂

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

    meri english week h thodi

  • @ayushbhandari1176
    @ayushbhandari1176 Před 2 lety

    is this the power of god

  • @akshaykumar192
    @akshaykumar192 Před 2 lety

    ye aapne kon si language me coding ki hai

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

    not understood hashmap logic

  • @mddanishraza5482
    @mddanishraza5482 Před rokem

    Why are you speak hindi in channel but your lecture only use English that's kabhi khushi channel se mila jab aap announced kia dsa ke bare me and now kabhi gum

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

    Such a bad explanation in map

    • @shreetejsanap1706
      @shreetejsanap1706 Před rokem

      No Bro, you should respect efforts! You might be unknown of the map concept.

    • @rahuldeb61
      @rahuldeb61 Před rokem +2

      Bro there is nothing related to respecting efforts. There may be 100 youtubers solving the same solution, all of them putting some effort to upload it but only few of them are able to talk clearly about the concepts I can also upload 100 dsa videos just by writting the codes. I can also put the same effort but whats the point when the viewers dont get the logic behind those codes. Channels like love babbar, striver are far way better when it comes to putting efforts.

    • @jay8118
      @jay8118 Před rokem

      @@rahuldeb61 True...Striver is the best when it comes to explanation...Every topic in minute detail...But Fraz is also good for quick revising concepts