Two Sum Problem | Basic and HashMap Approach | Leetcode 1

preview_player
Показать описание
Explained What is Two Sum leetcode problem. What is the basic approach to solve then improved with HashMap solution.

Link for other important DS & Algo problems videos:

If you find this video helpful for you then PLEASE help our channel by SUBSCRIBING and LIKE.

#coding #leetcode #tech #software #faang #datastructure #algorithm #java #interview #placement
Рекомендации по теме
Комментарии
Автор

beautful explanation out of all the youtube, keep making more

Jepi
Автор

What is the time complexity of using the hashmap compared to the first approach?

Diana-ufqv
Автор

Is it necessary to put again map.put(num, i) without this code is incomplete?

VivekYadav-sgte
Автор

You don't hadmapfor this
you can just for loop (iterate the list) one time to get value
python
def findtarget(lists, target):
for indx, val in enumerate(lists):
first_index = 0
remaining = target - lists[first_index] # so we need to iterate until we get this remaining variable value
if (val == remaining):
return [indx, first_index]


print(findtarget([2, 2, 11, 9], 11))

mohamedrasvi