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

No comments:

Post a Comment