Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commita1e6274

Browse files
refactor 1043
1 parent9710743 commita1e6274

File tree

1 file changed

+3
-16
lines changed

1 file changed

+3
-16
lines changed

‎src/main/java/com/fishercoder/solutions/_1043.java

Lines changed: 3 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1,23 +1,10 @@
11
packagecom.fishercoder.solutions;
22

3-
/**
4-
* 1043. Partition Array for Maximum Sum
5-
*
6-
* Given an integer array A, you partition the array into (contiguous) subarrays of length at most K. After partitioning, each subarray has their values changed to become the maximum value of that subarray.
7-
* Return the largest sum of the given array after partitioning.
8-
*
9-
* Example 1:
10-
* Input: A = [1,15,7,9,2,5,10], K = 3
11-
* Output: 84
12-
* Explanation: A becomes [15,15,15,9,10,10,10]
13-
*
14-
* Note:
15-
* 1 <= K <= A.length <= 500
16-
* 0 <= A[i] <= 10^6
17-
* */
183
publicclass_1043 {
194
publicstaticclassSolution1 {
20-
/**credit: https://leetcode.com/problems/partition-array-for-maximum-sum/discuss/290863/JavaC%2B%2BPython-DP*/
5+
/**
6+
* credit: https://leetcode.com/problems/partition-array-for-maximum-sum/discuss/290863/JavaC%2B%2BPython-DP
7+
*/
218
publicintmaxSumAfterPartitioning(int[]A,intK) {
229
intN =A.length;
2310
int[]dp =newint[N];

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp