EvergreenTree97 / Rokorithm

๐Ÿ’ช 1 ๋ถ€ํ„ฐ ์‹œ์ž‘ํ•˜๋Š” ์•Œ๊ณ ๋ฆฌ์ฆ˜
0 stars 0 forks source link

2023/07/05 #41

Open EvergreenTree97 opened 1 year ago

EvergreenTree97 commented 1 year ago

1149 RGB ๊ฑฐ๋ฆฌ silver 1

EvergreenTree97 commented 1 year ago

๊ฐ ๋‹จ๊ณ„์—์„œ R, G, B์— ๊ทธ๋ฆด๋•Œ์˜ ์ตœ์†Ÿ๊ฐ’์„ ๊ณ„์‚ฐํ•˜๋Š” ๊ฒƒ์ด ์ด ๋ฌธ์ œ์˜ ํ•ต์‹ฌ. ์ฒซ ๋ฒˆ์งธ ์ง‘์—์„œ R, G, B๋ฅผ ์น ํ•˜๊ณ , ๋‹ค์Œ ์ง‘๋ถ€ํ„ฐ ์ „์— ์น ํ–ˆ๋˜ ์ƒ‰์ƒ์„ ์ œ์™ธํ•œ ๋‹ค๋ฅธ ์ƒ‰์ƒ์˜ ์ตœ์†Œ๊ฐ’์„ ๊ธฐ์–ตํ•˜๋ฉด์„œ ๊ณ„์‚ฐํ•ด๊ฐ

EvergreenTree97 commented 1 year ago

์žฌ๊ท€ ๋ฒ„์ „

fun recur(N: Int, color: Int, dp:Array<IntArray>){
    if(dp[N][color] == 0){
        when(color){
            0 -> dp[N][0] = min(dp[N-1][1], dp[N-1][2])
            1 -> dp[N][1] = min(dp[N-1][0], dp[N-1][2])
            2 -> dp[N][2] = min(dp[N-1][0], dp[N-1][1])
        }
    }
    return dp[N][color]
}
EvergreenTree97 commented 1 year ago

10867 ์ค‘๋ณต ๋นผ๊ณ  ์ •๋ ฌํ•˜๊ธฐ silver 5