FazBrowse GitHub Viewer
|
Trending
|
URL:
|
Home
Tools:
[Download Repo ZIP]
[View Raw Code]
[Original HTTPS Page]
leetcode-solutions/decode_ways.cpp at master · avidLearnerInProgress/leetcode-solutions · GitHub
avidLearnerInProgress
/
leetcode-solutions
Public
Notifications
You must be signed in to change notification settings
Fork
5
Star
19
Code
Issues
0
Pull requests
0
Actions
Projects
Security and quality
0
Insights
Additional navigation options
Code
Issues
Pull requests
Actions
Projects
Security and quality
Insights
Expand file tree
Breadcrumbs
leetcode-solutions
/
decode_ways.cpp
Copy path
More file actions
More file actions
Latest commit
History
History
History
43 lines (34 loc) · 931 Bytes
Breadcrumbs
leetcode-solutions
/
decode_ways.cpp
Copy path
File metadata and controls
43 lines (34 loc) · 931 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
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
class
Solution
{
public:
int
numDecodings
(string s) {
int
n = s.
size
();
int
total =
1
;
int
single_count =
1
;
if
(s[
0
]==
'
0
'
)
return
0
;
for
(
int
i=n-
2
; i>=
0
; i--)
{
if
(s[i+
1
]==
'
0
'
and
(s[i]>
'
2
'
|| s[i]==
'
0
'
))
return
0
;
if
(s[i]==
'
0
'
)
continue
;
if
(s[i+
1
]==
'
0
'
)
{
single_count=
0
;
continue
;
}
if
(s[i]>
'
2
'
|| s[i+
1
]>
'
6
'
and
s[i]==
'
2
'
)
{
single_count = total;
continue
;
}
else
{
int
temp = total;
total = total+single_count;
single_count = single_count + (temp-single_count);
}
}
return
total;
}
};
Back
|
FazBrowse Home
|
New Git URL