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

Commite33d653

Browse files
author
wb-hjk570755
committed
动态规划
1 parent0d73c0e commite33d653

File tree

1 file changed

+11
-0
lines changed

1 file changed

+11
-0
lines changed

‎src/com/blankj/easy/_053/Solution.java

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -45,4 +45,15 @@ public static void main(String[] args) {
4545
int[]nums0 =newint[]{-2,1, -3,4, -1,2,1, -5,4};
4646
System.out.println(solution.maxSubArray(nums0));
4747
}
48+
49+
publicintmaxSubArrayByD(int[]nums) {
50+
intlen =nums.length,dp =nums[0],max =dp;
51+
for (inti =1;i <len; ++i) {
52+
dp =nums[i] + (dp >0 ?dp :0);
53+
if (dp >max) {
54+
max =dp;
55+
}
56+
}
57+
returnmax;
58+
}
4859
}

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp