Skip to content
Toggle navigation
P
Projects
G
Groups
S
Snippets
Help
李楚霏
/
leetCode_Solution_Record
This project
Loading...
Sign in
Toggle navigation
Go to a project
Project
Repository
Issues
0
Merge Requests
0
Pipelines
Wiki
Snippets
Members
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Commit
4b584bef
authored
Oct 04, 2020
by
李楚霏
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
move file
parent
c4416e3d
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
0 additions
and
22 deletions
+0
-22
70works/week6/decode_ways.js
+0
-22
No files found.
70works/week6/decode_ways.js
deleted
100644 → 0
View file @
c4416e3d
/**
* @param {string} s
* @return {number}
*/
var
numDecodings
=
function
(
s
)
{
if
(
!
s
)
return
0
;
let
len
=
s
.
length
;
let
dp
=
new
Array
(
len
+
1
).
fill
(
0
);
dp
[
0
]
=
1
;
dp
[
1
]
=
s
[
0
]
===
'0'
?
0
:
1
;
for
(
let
i
=
2
;
i
<=
len
;
i
++
)
{
if
(
s
[
i
-
1
]
!==
'0'
)
{
dp
[
i
]
+=
dp
[
i
-
1
];
}
if
(
s
[
i
-
2
]
===
'1'
||
(
s
[
i
-
2
]
===
'2'
&&
s
[
i
-
1
]
>=
0
&&
s
[
i
-
1
]
<=
6
))
{
dp
[
i
]
+=
dp
[
i
-
2
];
}
}
return
dp
[
len
];
};
\ No newline at end of file
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment