Skip to content

Instantly share code, notes, and snippets.

@SeemabMehmood
Created September 20, 2023 04:48
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save SeemabMehmood/94c59d96a74c858c9fa3fdbbb9273ec0 to your computer and use it in GitHub Desktop.
Save SeemabMehmood/94c59d96a74c858c9fa3fdbbb9273ec0 to your computer and use it in GitHub Desktop.
Running Sum
n = [3, 1, 2, 10, 1]
for i in n.length
n[i] += n[i-1]
end
# Time Complexitiy: O(n)
# Space Complexity: constant O(1)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment