classSolution: defisPalindrome(self, s: str) -> bool: left, right = 0, len(s) - 1 while left < right: whilenot (s[left].isalpha() or s[left].isnumeric()) and left < right: left += 1 whilenot (s[right].isalpha() or s[right].isnumeric()) and left < right: right -= 1 if s[left].lower() != s[right].lower(): returnFalse left += 1 right -= 1 returnTrue
classSolution: defmaxArea(self, height: List[int]) -> int: l, r = 0, len(height)-1 result = 0 while l < r: result = max(result, min(height[r], height[l]) * (r-l)) if height[l] == height[r]: l += 1 r -= 1 elif height[l] < height[r]: l += 1 else: r -= 1 return result
classSolution: defthreeSum(self, nums: List[int]) -> List[List[int]]: nums.sort() l, r, m = 0, len(nums) - 1, 1 result = [] for i inrange(len(nums)): if i > 0and nums[i] == nums[i-1]: continue l, r = i+1, len(nums) - 1 while l < r: curr_val = nums[l] + nums[r] if curr_val == -nums[i]: result.append([nums[i], nums[l], nums[r]]) l += 1 while nums[l] == nums[l - 1] and l < r: l += 1 elif curr_val > -nums[i]: r -= 1 else: l += 1 return result