Notice
Recent Posts
Recent Comments
Link
일 | 월 | 화 | 수 | 목 | 금 | 토 |
---|---|---|---|---|---|---|
1 | ||||||
2 | 3 | 4 | 5 | 6 | 7 | 8 |
9 | 10 | 11 | 12 | 13 | 14 | 15 |
16 | 17 | 18 | 19 | 20 | 21 | 22 |
23 | 24 | 25 | 26 | 27 | 28 |
Tags
- leetcode풀기
- LeetCode
- 릿코드
- python zip_longest
- python 릿코드
- 파이썬 알고리즘
- python xor
- 파이썬 릿코드
- 릿코드풀이
- 파이썬 알고리즘 풀기
- 파이썬릿코드
- leetcode풀이
- python 알고리즘
- python sorted
- 파이썬알고리즘
- 릿코드 풀기
- 릿코드 파이썬
- 파이썬릿코드풀기
- python Leetcode
- 알고리즘풀이
- 알고리즘풀기
- 코틀린기초
- 상가수익률계산기
- 파이썬알고리즘풀기
- 잇츠디모
- leetcode 풀기
- python priority queue
- 릿코드풀기
- binary search
- 파이썬 프로그래머스
Archives
- Today
- Total
소프트웨어에 대한 모든 것
LeetCode 풀이 - 1480. Running Sum of 1d Array 본문
반응형
Running Sum of 1d Array
문제)
솔루션1)
class Solution:
def runningSum(self, nums: List[int]) -> List[int]:
ret = [nums[0]]
for i in range(1, len(nums)):
ret.append(ret[i-1] + nums[i])
return ret
솔루션2)
from itertools import accumulate
class Solution:
def runningSum(self, nums: List[int]) -> List[int]:
return list(accumulate(nums))
힌트)
itertools.accumulate() 함수는 누적합을 계산
반응형
'알고리즘 > LeetCode' 카테고리의 다른 글
LeetCode 풀이 - 1828. Queries on Number of Points Inside a Circle (0) | 2021.10.16 |
---|---|
LeetCode 풀이 - 1672. Richest Customer Wealth (0) | 2021.10.16 |
LeetCode 풀이 - 2011. Final Value of Variable After Performing Operations (0) | 2021.10.16 |
LeetCode 풀이 - 1929. Concatenation of Array (0) | 2021.10.16 |
LeetCode 풀이 - 1920. Build Array from Permutation (0) | 2021.10.16 |
Comments