deno.land / x / masx200_leetcode_test@10.6.5 / ba-shu-zi-fan-yi-cheng-zi-fu-chuan-lcof / index.go

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
package ba_shu_zi_fan_yi_cheng_zi_fu_chuan_lcof
import "strconv"
func translateNum(num int) int { var s = strconv.Itoa(num) var n = len(s) var dp = []int{1, 1} for i := 2; i < n+1; i++ { var o, e = strconv.Atoi(s[i-2 : i]) if e != nil { panic(e) } dp = append(dp, dp[1]+Btoi(9 < o && o < 26)*dp[0]) dp = dp[1:] } return dp[1]}func Btoi(b bool) int { if b { return 1 } return 0}
masx200_leetcode_test
leetcode题解和一些测试工具
DocumentationDocumentation
GitHub Repositorymasx200/leetcode-test
GitHub Stars
4

Version Info

Tagged at
4 months ago