/Time complexity - O(n) Secret
Last active
March 21, 2022 23:22
Time complexity - O(n)
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
function listSum(n) { | |
let result = 0; // Assign 數值給變數,執行 1 次 | |
for (let i = 0; i < n.length; i++) { // Loop array 執行 n 次 | |
result += n[i]; | |
} | |
return result; // Return 結果,執行 1 次 | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment