chromewebstore.google.com/detail/dsa-video-solutions/fplacgmeefidnohgepjcnabcaakfbknm Check out this cool extension with which you can unlock DSA video tutorial instantly on GeeksforGeeks with a single click. Its completely safe. Let me know if you have any suggestions.
sir what you explained is clear but i am confused why we are storing values in hst....even i am not able to build logic why 16-6=10 is present in hst😵💫
@AdityaSingh-nu4jl 0 seconds ago sir i have created this code in pytho but dont know why it's failing at 309th case of gfg ... my approch is searching in set has complexity of O(1) that'swhy target-x should be there in set.. my code is class Solution: def twoSum(self, arr, target): y = set(arr) # Convert the array to a set for x in arr: if (target - x) in y: return True return False
suppose array is [2,5] and target is 10. for x =5, I will check if target - 5 is present in set ? yes its present so your code will return true which is wrong. I hope you got it. :)
chromewebstore.google.com/detail/dsa-video-solutions/fplacgmeefidnohgepjcnabcaakfbknm
Check out this cool extension with which you can unlock DSA video tutorial instantly on GeeksforGeeks with a single click. Its completely safe.
Let me know if you have any suggestions.
amazing explanation
Glad it helped :)
Guyss please subscribe 🥰🥰🥰
sir what you explained is clear but i am confused why we are storing values in hst....even i am not able to build logic why 16-6=10 is present in hst😵💫
@AdityaSingh-nu4jl
0 seconds ago
sir i have created this code in pytho but dont know why it's failing at 309th case of gfg ...
my approch is searching in set has complexity of O(1) that'swhy target-x should be there in set..
my code is
class Solution:
def twoSum(self, arr, target):
y = set(arr) # Convert the array to a set
for x in arr:
if (target - x) in y:
return True
return False
suppose array is [2,5] and target is 10. for x =5, I will check if target - 5 is present in set ? yes its present so your code will return true which is wrong. I hope you got it. :)