Skip to content

feat: add code with self-implemented sum method #365

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
May 22, 2020

Conversation

suukii
Copy link
Contributor

@suukii suukii commented May 16, 2020

No description provided.

@@ -30,6 +30,21 @@ class Solution:
return cnt
```

如果我们自己实现子数组求和的话,时间复杂度是 O(n^3),代码如下:
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

没必要啊。 你可以两层循环就搞定的

for i in range(n):
            sum = 0
            for j in range(i, n):
				sum += nums[j] 

@azl397985856 azl397985856 merged commit 3e87026 into azl397985856:master May 22, 2020
azl397985856 pushed a commit that referenced this pull request Aug 19, 2023
* feat: add code with self-implemented sum method

* feat: 暴力法的O(n^2)实现
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants