Python Programming Website Solving Problems
I use an online judging system for coding problems here. If you’re good at English, you can use Codeforces and LeetCode. For Chinese, you can go to Bilibili and LeetCode. I use LeetCode here. I did 10 problems and optimized the program efficiency of the last problem from beating 10% of submissions to beating 99%.: Contest, Codeforces
jsk: Jikexueyuan (Chinese education platform) leetcode: LeetCode (online judge for coding interviews)1. Running Sum of 1D Array
Given an array nums
. The running sum of an array can be defined as runningSum[i] = sum(nums[0] to nums[i])
.1. Compute the sum s
of the list nums
and append it to running
.
- Return the list
running
.
class Solution:
def runningSum(self, nums: List[int]) -> List[int]:
running = []
s = 0
for num in nums:
s += num
running.append(s)
return running