File tree Expand file tree Collapse file tree 1 file changed +25
-0
lines changed Expand file tree Collapse file tree 1 file changed +25
-0
lines changed Original file line number Diff line number Diff line change 1+ ##==================================
2+ ## Leetcode
3+ ## Student: Vandit Jyotindra Gajjar
4+ ## Year: 2020
5+ ## Problem: 125
6+ ## Problem Name: Valid Palindrome
7+ ##===================================
8+ #
9+ #Given a string, determine if it is a palindrome,
10+ #considering only alphanumeric characters and ignoring cases.
11+ #
12+ #Note: For the purpose of this problem, we define empty string as valid palindrome.
13+ #
14+ #Example 1:
15+ #
16+ #Input: "A man, a plan, a canal: Panama"
17+ #Output: true
18+ #Example 2:
19+ #
20+ #Input: "race a car"
21+ #Output: false
22+ class Solution :
23+ def isPalindrome (self , s ):
24+ s = '' .join (i for i in s if i .isalnum ().lower ) #Initialize s where we join every word in one string and check for alphanumeric cases
25+ return s == s [::- 1 ] #Return true or false if our main s and reverse of s is same or not respectively
You can’t perform that action at this time.
0 commit comments