Skip to content

Commit 33c883d

Browse files
committed
add palindrome check algo
1 parent c6f814d commit 33c883d

File tree

1 file changed

+17
-0
lines changed

1 file changed

+17
-0
lines changed

misc/palindrome_check.py

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
""" Design an optimal algorithm for checking whether a given string is
2+
palindrome or not!
3+
"""
4+
5+
def check_palindrome(original):
6+
for i in range(len(original) // 2):
7+
if original[i] != original[len(original)-1-i]:
8+
return False
9+
return True
10+
11+
12+
def check_palindrome_pythonic(original):
13+
return original == original[::-1]
14+
15+
16+
print(check_palindrome_pythonic("madam"))
17+
print(check_palindrome("hello"))

0 commit comments

Comments
 (0)