๐ป Coding Problems Solving/Dynamic Programming
[LeetCode] Maximum Subarray
[LeetCode] Maximum Subarray 1. ๋ฌธ์ : Link ํ์ array ์ค ํฉ์ ์ต๋๊ฐ ์ฐพ๋ ๋ฌธ์ 2. ํ์ด array๋ฌธ์ ์ ํ์ ์๊ธธ๋ dp ์๊ฐ๋ ๋ชปํ๋๋ฐ dp ๋ฌธ์ ์ฌ๋ฐ... 3. ์ฝ๋ class Solution: def maxSubArray(self, nums: List[int]) -> int: dp = [num for num in nums] for i in range(1, len(nums)): dp[i] = max(dp[i-1]+nums[i], nums[i]) return max(dp) class Solution { public int maxSubArray(int[] nums) { int[] dp = new int[nums.length]; for(int i=0; i
2022. 7. 24. 16:56
์ต๊ทผ๋๊ธ