deno.land / x / masx200_leetcode_test@10.6.5 / decode-ways / index.ts

نووسراو ببینە
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
function numDecodings(s: string): number { const n = s.length;
let a = 0, b = 1, c = 0; for (let i = 1; i <= n; ++i) { c = 0; if (s[i - 1] !== "0") { c += b; } if ( i > 1 && s.charAt(i - 2) != "0" && Number(s.slice(i - 2, i)) <= 26 ) { c += a; } a = b; b = c; } return c;}export default numDecodings;
masx200_leetcode_test

Version Info

Tagged at
a year ago