leet code 53. Maximum Subarray
Given an integer array nums, find the contiguous subarray (containing at least one number) which has the largest sum and return its sum. Example: Input: [-2,1,-3,4,-1,2,1,-5,4], Output: 6 Explanation: [4,-1,2,1] has the largest sum = 6. 정수가 들어있는 배열 하나가 주어진다. 배열안에 들어있는 정수들 중에서 숫자들의 하위배열이 가장 큰 배열의 합을 리턴하는 문제이다. 풀이법 class Solution { public int maxSubArray(int[] nums) { int n = nums.length; int dp ;..
2020. 9. 5.