Two sum problem in Swift #swift #datastructuresandalgorithms #twosum

preview_player
Показать описание
Hey! Welcome to The Dummy Programmer! Thrilled to have you here!
I am working through all the problems on Leetcode to prepare for my technical interviews and I am recording these videos so I can chart my progress. The solutions are in Swift! I hope it helps you too! If it does, please like the video. Thank you for tuning in!

In this video, I have worked on two sum problem. I forgot to mention the time and space complexity. Since we walk through the array once here the time complexity is O(n) where n is the number of items in the input array. The time complexity is also O(n) because we use a dictionary to store the complement of every number in the array. In the worst case where no pairs exist, the dictionary will have as many elements as in the input array i.e., n.
Рекомендации по теме
join shbcf.ru