|
改写了别人 https://github.com/halfrost/LeetCode-Go/blob/master/leetcode/0091.Decode-Ways/91.%20Decode%20Ways.go 的答案,很快
with recursive
t(pos,s,dp,dp0) as (
select 1 ,'475237961189389388191145248534732735845769521294614894148884461898335373734122464165638621',1,0
union all
select t.pos+1,s
,case when substr(s,t.pos,1)<>'0' then dp else 0 end + case when pos >1 and substr(s,t.pos-1,1)<>'0' and cast(substr(s,t.pos-1,2) as int) between 1 and 26 then dp0 else 0 end,dp
from t
where pos<=length(s)+1
)
select pos,dp,dp0 from t
where t.pos=length(s)+1;
91|34560|17280
Run Time: real 0.001 user 0.000733 sys 0.000000 |
|