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

Commit48a95bf

Browse files
Merge pull requestneetcode-gh#3455 from Tetsuya3850/patch-6
2 parentse068b92 +f637818 commit48a95bf

File tree

1 file changed

+12
-0
lines changed

1 file changed

+12
-0
lines changed

‎java/0256-paint-house.java‎

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
classSolution {
2+
publicintminCost(int[][]costs) {
3+
int[]dp =newint[3];
4+
for (inti =0;i <costs.length;i++) {
5+
intdp0 =costs[i][0] +Math.min(dp[1],dp[2]);
6+
intdp1 =costs[i][1] +Math.min(dp[0],dp[2]);
7+
intdp2 =costs[i][2] +Math.min(dp[0],dp[1]);
8+
dp =newint[] {dp0,dp1,dp2 };
9+
}
10+
returnArrays.stream(dp).min().getAsInt();
11+
}
12+
}

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp