FazBrowse GitHub Viewer
|
Trending
|
URL:
|
Home
Tools:
[Download Repo ZIP]
[View Raw Code]
[Original HTTPS Page]
algorithms-python/dp/max_subarray.py at master · izanbf1803/algorithms-python · GitHub
izanbf1803
/
algorithms-python
Public
forked from
keon/algorithms
Notifications
You must be signed in to change notification settings
Fork
0
Star
0
Code
Pull requests
0
Actions
Projects
Wiki
Security and quality
0
Insights
Additional navigation options
Code
Pull requests
Actions
Projects
Wiki
Security and quality
Insights
Expand file tree
Breadcrumbs
algorithms-python
/
dp
/
max_subarray.py
Copy path
More file actions
More file actions
Latest commit
History
History
History
11 lines (9 loc) · 279 Bytes
Breadcrumbs
algorithms-python
/
dp
/
max_subarray.py
Copy path
File metadata and controls
11 lines (9 loc) · 279 Bytes
Raw
Copy raw file
Download raw file
Open symbols panel
Edit and raw actions
1
2
3
4
5
6
7
8
9
10
11
def
max_subarray
(
array
):
max_so_far
=
max_now
=
array
[
0
]
for
i
in
range
(
1
,
len
(
array
)):
max_now
=
max
(
array
[
i
],
max_now
+
array
[
i
])
max_so_far
=
max
(
max_so_far
,
max_now
)
return
max_so_far
a
=
[
1
,
2
,
-
3
,
4
,
5
,
-
7
,
23
]
print
(
a
)
print
(
max_subarray
(
a
))
Back
|
FazBrowse Home
|
New Git URL