Leetcode#121: Best Time to Buy and Sell Stock - Swift (Swift Programming & Algorithms)

preview_player
Показать описание
Tackling Leetcode#121: Best Time to Buy and Sell Stock question in Swift programming language.

Have seen many videos on Youtube tackling Leetcode questions and the solutions are primarily in Java or Python. I'm trying to grow this channel by doing Leetcode questions using Swift programming language. Hopefully this would be useful to Swift enthusiast or iOS developers

#ios #iosprogramming #swift #swiftprogramming #leetcode #leetcodequestions #swiftprogramming #algorithms #datastructures #besttimetobuyandsellstock #apple #appleprogramming #iosengineers #iosdevelopers
Рекомендации по теме
Комментарии
Автор

I think this video felt a bit rushed but thank you for making it. it would help to mention that we want to only increment start (buyPtr) only if we spot that end (sellPtr) is actually lower and we have spotted the new low. Some other videos start endPtr to 1 and BuyPtr to 0 as first step because you can't buy and sell on same day for this problem. So I was a bit confused when you set both start and end to 0 from the beginning. But nevertheless, elegant solution!

yoonsw
visit shbcf.ru