FazBrowse GitHub Viewer
|
Trending
|
URL:
|
Home
Tools:
[Download Repo ZIP]
[View Raw Code]
[Original HTTPS Page]
CodeTest/leetcode/decode-ways.cpp at master · wheatwaves/CodeTest · GitHub
wheatwaves
/
CodeTest
Public
forked from
flexwang-zz/CodeTest
Notifications
You must be signed in to change notification settings
Fork
0
Star
1
Code
Pull requests
0
Actions
Projects
Wiki
Security and quality
0
Insights
Additional navigation options
Code
Pull requests
Actions
Projects
Wiki
Security and quality
Insights
Expand file tree
Breadcrumbs
CodeTest
/
leetcode
/
decode-ways.cpp
Copy path
More file actions
More file actions
Latest commit
History
History
History
17 lines (17 loc) · 436 Bytes
Breadcrumbs
CodeTest
/
leetcode
/
decode-ways.cpp
Copy path
File metadata and controls
17 lines (17 loc) · 436 Bytes
Raw
Copy raw file
Download raw file
Open symbols panel
Edit and raw actions
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
class
Solution
{
public:
int
numDecodings
(string s) {
int
len = s.
length
();
if
(len==
0
)
return
0
;
int
dp[len+
1
];
dp[
0
] =
1
;
for
(
int
i=
1
; i<=len; i++) {
dp[i] =
0
;
if
(s[i-
1
] !=
'
0
'
)
dp[i] += dp[i-
1
];
if
(i-
2
>=
0
&& s[i-
2
]!=
'
0
'
&& (s[i-
2
]-
'
0
'
)*
10
+s[i-
1
]-
'
0
'
<=
26
)
dp[i] += dp[i-
2
];
}
return
dp[len];
}
};
Back
|
FazBrowse Home
|
New Git URL