0
0

More than 3 years have passed since last update.

サブ配列の最大値抽出(最大部分配列)

Posted at

趣旨

以前、転職活動のコーディングテストで
最大部分配列をreturnで返す問題を出題されたため
pythonで書いてみました。

python
def maxSubArray(self, nums: List[int]) -> int:
    dp = [0 for _ in range(len(nums))]
    dp[0] = nums[0]
    for i in range(1, len(nums)):
        dp[i] = max(dp[i-1]+nums[i], nums[i])
    return max(dp)
0
0
5

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
0