Skip to content

Commit fbcf1f1

Browse files
Merge pull request #169 from HmmCorn/liv
땅따먹기
2 parents db38579 + 3dbe382 commit fbcf1f1

1 file changed

Lines changed: 18 additions & 0 deletions

File tree

  • WEEK16/프로그래머스_땅따먹기
Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
// 프로그래머스 - 땅따먹기
2+
3+
import Foundation
4+
5+
func solution(_ land: [[Int]]) -> Int {
6+
let n = land.count
7+
var dp = land
8+
9+
for row in 1..<n {
10+
for col in 0..<4 {
11+
var previous = dp[row - 1]
12+
previous[col] = 0
13+
dp[row][col] += previous.max()!
14+
}
15+
}
16+
17+
return dp[n - 1].max()!
18+
}

0 commit comments

Comments
 (0)