Created
September 20, 2023 04:48
-
-
Save SeemabMehmood/94c59d96a74c858c9fa3fdbbb9273ec0 to your computer and use it in GitHub Desktop.
Running Sum
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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