Skip to content

Commit

Permalink
add sol
Browse files Browse the repository at this point in the history
  • Loading branch information
ductnn committed May 17, 2024
1 parent 8900229 commit 3295c6c
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 0 deletions.
21 changes: 21 additions & 0 deletions leetcode/1480.RunningSumof1dArray/sol.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
// https://leetcode.com/problems/running-sum-of-1d-array/description/

package main

import (
"fmt"
)

func runningSum(nums []int) []int {
for i := 1; i < len(nums); i++ {
nums[i] += nums[i-1]
}

return nums
}

func main() {
nums := []int{1, 1, 1, 1, 1}

fmt.Println(runningSum(nums))
}
6 changes: 6 additions & 0 deletions leetcode/1480.RunningSumof1dArray/sol.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
class Solution:
def runningSum(self, nums: List[int]) -> List[int]:
for i in range(1, len(nums)):
nums[i] += nums[i-1]

return nums

0 comments on commit 3295c6c

Please sign in to comment.