my attempt at solving leetcode 1: two sum [SOLVED]

preview_player
Показать описание
Hi there, my motive behind this video is to be able to solve a leetcode problem utilising the rubber ducky debugging method, but I hope this helps anyone watching and discussions are very welcome in the comments! :

Рекомендации по теме
Комментарии
Автор

its one of the efficient method (but not the best) is to sort the array and take two pointers, one from start and one from end and checking for the required sum. Its complexity will be O(nlogn) (better than your O(n^2) solution). The best method is to take a map (it's in c++, Idk what it's called in python) and store the elements (O(n)).

codingvibes
join shbcf.ru