Software Engineering/Algorithm7 [리트코드] 53. Maximum Subarray (DP, Kadane's algorithm) 문제 정보 Given an integer array nums, find the contiguous subarray (containing at least one number) which has the largest sum and return its sum. A subarray is a contiguous part of an array. 문제 풀이 단순하게 모든 부분합을 반복하며 최대값을 구해 저장할 수 도 있겠지만 이는 O(n^2) 시간복잡도를 가진다. DP나 카데인 알고리즘을 사용하여 풀이하면 O(n)으로 해결할 수 있다. Kadane's algorithm 이란? The simple idea of Kadane’s algorithm is to look for all positive contiguous se.. 2022. 1. 25. 이전 1 2 다음