Skip to content

Instantly share code, notes, and snippets.

@BharathKumarS
Created February 22, 2020 22:08
Show Gist options
  • Save BharathKumarS/ccc3c99a9e8ff5d642ff2df55b6d6df6 to your computer and use it in GitHub Desktop.
Save BharathKumarS/ccc3c99a9e8ff5d642ff2df55b6d6df6 to your computer and use it in GitHub Desktop.
LeetCode - Check for Palindrome - Check for 3 line code solution on my git repo
#Can you believe I wrote another solution with just 3 lines of code? Check my Git repo for the actual code!
class Palindrome:
def text(self, set_of_chars):
rev = clean = ''
for char in set_of_chars[::-1]:
if char.isalnum():
rev = rev + char.lower()
for ele in set_of_chars[::1]:
if ele.isalnum():
clean = clean + ele.lower()
print(clean == rev)
if __name__ == '__main__':
cObj = Palindrome()
cObj.text(str(input()))
@BharathKumarS
Copy link
Author

image

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment