53. 最大子序和-简单

53. 最大子序和
动态规划 解法
- 时间复杂度 O(n)
一次遍历,其中 n 为 nums 数组的长度。我们只需要遍历一遍数组即可求得答案。 - 空间复杂度 O(1)
只开辟了两个额外的空间,即只需要常数空间存放若干变量。
1 | func maxSubArray(_ nums: [Int]) -> Int { |
- Post title:53. 最大子序和-简单
- Post author:xxxixxxx
- Create time:2021-02-23 09:59:00
- Post link:https://xxxixxx.github.io/2021/02/23/2000-007-53. 最大子序和/
- Copyright Notice:All articles in this blog are licensed under BY-NC-SA unless stating additionally.
Comments