avatar
Siz Long

My name is Siz. I am a computer science graduate student specializing in backend development with Golang and Python, seeking opportunities in innovative tech projects. My personal website is me.longsizhuo.com .Connect with me on LinkedIn: https://www.linkedin.com/in/longsizhuo/.

  • Resume
  • Archives
  • Categories
  • Photos
  • Music



{{ date }}

{{ time }}

avatar
Siz Long

My name is Siz. I am a computer science graduate student specializing in backend development with Golang and Python, seeking opportunities in innovative tech projects. My personal website is me.longsizhuo.com .Connect with me on LinkedIn: https://www.linkedin.com/in/longsizhuo/.

  • 主页
  • Resume
  • Archives
  • Categories
  • Photos
  • Music

122.The best time for buying and selling stocksII

  2024-01-01        
字数统计: 92字   |   阅读时长: 1min

topic:

screenshot2023-10-02 afternoon11.16.25.png

122.The best time for buying and selling stocksII.md

Thought:

I can forget that the price will be reduced the price one day after the first day.,Thinking is to build the minimum child。
Then I found that it seems a bit complicated,Have done it again(2023.1.13),I found out that it seems that only one line can be done。

Code:

1
2
3
class Solution:
def maxProfit(self, prices: List[int]) -> int:
return sum(max(0, prices[i] - prices[i - 1]) for i in range(1, len(prices)))
  • Python
  • answer
  • Array
  • Dynamic planning
  • greedy

扫一扫,分享到微信

微信分享二维码
121.The best time for buying and selling stocks
1222.Can attack the queen of the king
目录
  1. 1. topic:
  2. 2. Thought:
  3. 3. Code:

150 篇 | 131.7k
次 | 人
这里自动载入天数这里自动载入时分秒
2022-2025 loong loong | 新南威尔士龙龙号