Grokking Data Structures & Algorithms for Coding Interviews
Ask Author
Back to course home

0% completed

Vote For New Content
Mohammed Dh Abbas
Simpler way!

Mohammed Dh Abbas

Aug 30, 2024

class Solution: def isPalindromePossible(self, s: str) -> bool: i = 0 j = len(s) - 1 count = 0 while i < j: if count > 1: return False if s[i] == s[j]: i += 1 j -= 1 else: if s[i + 1] == s[j]: i += 1 elif s[j - 1] == s[i]: j -= 1 else: return False count += 1 return True

1

0

Comments
Comments
P
Pete Stengera year ago
class Solution:     def isPalindromePossible(self, s: str) -> bool:         # ToDo: Write Your Code Here.         # Don't use any space, just try the removal greedily         used = False         j = len(s) - 1         for i in range(len(s)):             if i ...

On this page