Watch this if you want to work at FAANG | Two Sum - Leetcode 1

preview_player
Показать описание
leetcode, coding interview question, data structures, data structures and algorithms, faang
Рекомендации по теме
Комментарии
Автор

Master Data Structures & Algorithms For FREE at AlgoMap.io!

GregHogg
Автор

If a company fails someone for starting with an O(n^2) solution, don’t work for them.

Starting with a naive solution and refining it iteratively is the correct method for developing algorithms.

dacjames
Автор

If the array is sorted then we can solve this with O(1) space complexity with a two pointer solution. I was asked two sum in an interview where the array was sorted and that was the solution. If the array is not sorted then we must use a hashmap or hashset depending on the variant of two sum they ask in the interview

Garensonic
Автор

Sounds alright, but you don't check if y exists a a key for the dictionary???

handmadesoap
Автор

If i in d: this itself isn't a loop?

blazemates