Three sum problem in Swift
Вставка
- Опубліковано 8 лип 2023
- 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!
I forgot to mention the time complexity of the solution. So here goes -
For the sorting it is going to be nlogn
For the loop, it is going to be n^2
So the total is going to be nlogn + n^2. We can drop nlogn since we only care about the highest number. So the time complexity of this solution is O(n^2).
We don't use any extra space except for the value that we return. So the space complexity is O(1).
It was so nicely explained keep up the good work 😊
Good job … keep going 👍🏼
Thanks