Valid Palindrome - Leetcode 125 - 2 Pointers (Python)

preview_player
Показать описание


Please check my playlists for free DSA problem solutions:

My Favorite Courses:

Data Structures & Algorithms:

Python:

Web Dev / Full Stack:

Cloud Development:

Game Development:

SQL & Data Science:

Machine Learning & AI:
Рекомендации по теме
Комментарии
Автор

Master Data Structures & Algorithms For FREE at AlgoMap.io!

GregHogg
Автор

Great explanation brother, thanks
From India 🎉🎉❤

Code_Creator
Автор

s = ''.join(c for c in s if c.isalnum())
s = s.lower()
if s == s[::-1]:
return True
return False
can solve it like this as well without using pointer but space complexity is now o(n)

vidhansaini
Автор

def isPalindrome(word):
return word.lower() ==

mikekertser
Автор

Can we solve the same problem using recursion? if yes, how can we do it. I'm trying to do so but I'm not getting it. Thanks in advance.

manishluckyreddy
Автор

isalnum() check is not required i guess for both L and R

ashokramesh
Автор

explain this bro :
class Solution(object):
def isPalindrome(self, s):
return re.sub(r'[^A-Za-z0-9]', '', s.lower())==re.sub(r'[^A-Za-z0-9]', '', s.lower()[::-1])

technicallytechnical
Автор

YOUR ANSWER WILL GAVE WRONG ANSWER IT'S NOT VALID CHECK THAT '1P'

AbdelrhmanAdel-yb
Автор

Also:

def isPalindrome(s: str):
# Clean s
str_cleaned = ''.join(char.lower() for char in s if char.isalpha())
# Compare forward to backward
return str_cleaned == str_cleaned[::-1]

roccococolombo
visit shbcf.ru