leetcode 1. 两数之和
遍历数组即可
时间复杂度:O(n)
空间复杂度:O(n)
1 | class Solution: |
遍历数组即可
时间复杂度:O(n)
空间复杂度:O(n)
1 | class Solution: |
遍历二叉树即可
时间复杂度:O(n)
空间复杂度:O(1)
1 | # Definition for a binary tree node. |
滑动窗口
1 | class Solution: |
定义f(i):以第i个数结尾的连续子数组的最大和
答案即为:max(f(i)), 0<=i<n
f(i) = max(f(i-1)+num[i], num[i])
时间复杂度:O(n), 空间复杂度:O(1)
1 | class Solution: |
中心扩展法
1 | class Solution: |
Welcome to Hexo! This is your very first post. Check documentation for more info. If you get any problems when using Hexo, you can find the answer in troubleshooting or you can ask me on GitHub.
1 | $ hexo new "My New Post" |
More info: Writing
1 | $ hexo server |
More info: Server
1 | $ hexo generate |
More info: Generating
1 | $ hexo deploy |
More info: Deployment