Given an array of integers nums, return the sum of all elements.
This is your first real coding problem in the Big O section. The optimal solution is O(n) — you must visit every element exactly once.
nums = [1, 2, 3, 4, 5]15nums = [-1, 0, 1]0nums = [42]421 <= nums.length <= 10^5-10^4 <= nums[i] <= 10^4Expected time complexity: O(n)Run your code to see results
Use Cmd+Enter to run