Explanation for the article: www.geeksforgeeks.org/write-a-... This video is contributed by Harshit Jain.
Пікірлер: 40
@yazanshakhshir30496 жыл бұрын
if i just knew this channel before going to my last interview i would have got the job :( the interviewer asked me this question and i wasn't able to solve it using the hashmap method i am very upset to find out how much easy the solution is :(
@reyou77 жыл бұрын
Yet another great video! Thanks G4G!
@sounavapal7625 жыл бұрын
What about the extra space that we use for the hash array?
@rahulkumar-uw4os4 жыл бұрын
sir what about sum=2 in the following example given at 0:26 using hashmap technique
@akash77524 жыл бұрын
what if sum value is -ve then how to solve using hashmap?
@adityavarma10774 жыл бұрын
use unordered set
@NEXAWAY5 жыл бұрын
the bool map will not work if there is repetitions in the array?
@hermesmercuriustrismegistu48414 жыл бұрын
In Python you do not need to know the range of the hash map ie Python dictionary since they have dynamic sizes. I found Python to be a very useful language for coding interviews. Anyway thx a lot for the video!
@Bhatonia_Jaat3 жыл бұрын
u may be right but c++is way faster than python and also u can make dynamic arrays/hashmaps in cpp
@sunfline2 жыл бұрын
Python is shit
@rapperstories54633 жыл бұрын
Can someone explain third method i.e using remainders of the elements less than x....i couldnt find any video related to it
@pradeepshetty37782 жыл бұрын
how you find the indices?
@Sahil-explorer4 жыл бұрын
Using brute force approach we can do it too using two for loops but worst time is O(n^2).
@ravkrgmail3 жыл бұрын
How does it work if the array has billions elements?
@user-ke9xj2mh4f2 жыл бұрын
Wow!! Math and hashmap are two wonderful creation of the coding universe ❤️❤️❤️❤️❤️ thanks a lot! This is amazing 🤩🤩🤩🤩🤩🤩🤩🤩🤩🤩 I get the algorithm now
@divyansh595 жыл бұрын
I like the way u r teaching sir it's geat;
@ravindrasutar74906 жыл бұрын
i want to display those numbers in array..
@joydeepbhattacharjee53053 жыл бұрын
The second method will never work if there is negative number in the given set of number (For C lang)
@DigitalOutlawed4 жыл бұрын
thank you soooooooooo much my kind sir
@nshukla67 жыл бұрын
With Hashing technique what if numbers are duplicate
@GeeksforGeeksVideos7 жыл бұрын
Hi Nitin, If the numbers are duplicate, then the algorithm will set the binary hash map twice. So, we will still get the same results.
@ishumba3 жыл бұрын
@@GeeksforGeeksVideos Given an array [1, 5, 3, 3, 3] and sum 6, this algorithm gives a result of 3 instead of 4 being {1,5}, {3,3}, {3,3}, {3,3}.
@axel91943 жыл бұрын
In hash method the program not working
@mohammadmujahid88504 жыл бұрын
Why u r using hasmap for second method, hashset is better here.
@namanshah26882 жыл бұрын
very useful thanks !!
@combofriend44612 жыл бұрын
I don't think hashmap solution works right of there are dups
@marthamontes16366 жыл бұрын
Damn i need to know wtf the sum is im in third im thinking about it so hard what about you give the awnser to the ppl???
@aakashmudigonda33754 жыл бұрын
I didn't understand the second method
@alexanderarea61573 жыл бұрын
Sliding window will work here
@wecan27293 жыл бұрын
class Solution{ public: // Function to check if array has 2 elements // whose sum is equal to the given value bool hasArrayTwoCandidates(int arr[], int n, int x) { mapmp; for(int i=0;i
@rajdave98625 жыл бұрын
OMnS How can you think that please please omNs 🕉 please reply me How can you think like it
@simplybish6 жыл бұрын
binMap[arr[i]] = 1 ---> This line in code will throw index out of bound if the array has negative numbers.
@sounavapal7625 жыл бұрын
Bishwanath Singh in this case we'll have to keep an extra check
@jeanettenguyen22655 жыл бұрын
it's a dictionary/hashmap not an array
@joydeepbhattacharjee53053 жыл бұрын
@@jeanettenguyen2265 well C lang dont have dictionary or hashmap so this approach can be done with C Bishwanath Singh is most probably talking about C lang
@akshaydwivedi9355 жыл бұрын
Basically a binary search
@shiveshsingh24457 жыл бұрын
fair
@marthamontes16366 жыл бұрын
Yet i guess you made not my day :/
@theoneinyou2233 Жыл бұрын
Can it be simpler more like ... Map m= new HashMap(); for(i=0;i