Skip to content

Python Code Incorrectness #10

@Suhavi

Description

@Suhavi

an example - solution for max sum subarray, chapter 2

O(n^3) solution

best = 0
for i in arr:
for j in arr:
sum = 0
for k in arr:
sum += k
best = max(best, sum)
print(best)

real code -

best = 0
for i in range(0,len(arr)):
for j in range(0,len(arr)):
sum = 0
for k i range(i,j):
sum += k
best = max(best, sum

print(best)

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions