mirror of
https://gitlab.com/mfocko/LeetCode.git
synced 2024-11-09 15:59:06 +01:00
go: add «790. Domino and Tromino Tiling»
Signed-off-by: Matej Focko <me@mfocko.xyz>
This commit is contained in:
parent
97bc690403
commit
ef9c473c21
1 changed files with 14 additions and 0 deletions
14
go/domino-and-tromino-tiling.go
Normal file
14
go/domino-and-tromino-tiling.go
Normal file
|
@ -0,0 +1,14 @@
|
||||||
|
package main
|
||||||
|
|
||||||
|
const MOD int = 1_000_000_007
|
||||||
|
|
||||||
|
func numTilings(n int) int {
|
||||||
|
dp := [...]int{0, 1, 2, 5}
|
||||||
|
|
||||||
|
for n >= 4 {
|
||||||
|
dp[0], dp[1], dp[2], dp[3] = dp[1], dp[2], dp[3], (2*dp[3]+dp[1])%MOD
|
||||||
|
n--
|
||||||
|
}
|
||||||
|
|
||||||
|
return dp[n]
|
||||||
|
}
|
Loading…
Reference in a new issue