FazBrowse GitHub Viewer
|
Trending
|
URL:
|
Home
Tools:
[Download Repo ZIP]
[View Raw Code]
[Original HTTPS Page]
Python/pattern.py at main · melophilecode/Python · GitHub
melophilecode
/
Python
Public
Notifications
You must be signed in to change notification settings
Fork
0
Star
0
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
Python
/
pattern.py
Copy path
More file actions
More file actions
Latest commit
History
History
History
30 lines (23 loc) · 625 Bytes
Breadcrumbs
Python
/
pattern.py
Copy path
File metadata and controls
30 lines (23 loc) · 625 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
def
search
(
pat
,
txt
):
M
=
len
(
pat
)
N
=
len
(
txt
)
# A loop to slide pat[] one by one */
for
i
in
range
(
N
-
M
+
1
):
print
(
i
)
j
=
0
# For current index i, check
# for pattern match */
while
(
j
<
M
):
if
(
txt
[
i
+
j
]
!=
pat
[
j
]):
break
j
+=
1
if
(
j
==
M
):
print
(
"Pattern found at index "
,
i
)
# Driver's Code
if
__name__
==
'__main__'
:
txt
=
"AABAACAADAABAAABAA"
pat
=
"AABA"
# Function call
search
(
pat
,
txt
)
# This code is contributed
# by PrinciRaj1992
Back
|
FazBrowse Home
|
New Git URL