Sylvia at Hades Mercury
Friday, 1 February 2019
LeetCode Q121 Best Time to Buy and Sell Stock
Q121 Best Time to Buy and Sell Stock
record the lowest price
check delta-price and record it as maxProfie if find a greater one
time complexity O(n), just travesing the array once
space complexity O(1), only two variables
https://github.com/Sylvia-YiyinShen/Algorithm/blob/master/DynamicProgramming/Q121BestTimeForStock.playground/Contents.swift
No comments:
Post a Comment
Newer Post
Older Post
Home
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment