bugfree Icon
interview-course
interview-course
interview-course
interview-course
interview-course
interview-course
interview-course
interview-course

Leetcode Problem 125. Valid Palindrome

125. Valid Palindrome

Leetcode Solutions

Approach: Compare with Reverse

  1. Initialize an empty string to store the filtered characters.
  2. Iterate through each character in the input string.
  3. For each character, check if it is alphanumeric.
  4. If it is alphanumeric, convert it to lowercase if it is an uppercase letter, and append it to the filtered string.
  5. Reverse the filtered string.
  6. Compare the filtered string with its reversed version.
  7. If they are the same, return true, indicating that the input string is a palindrome.
  8. If they are not the same, return false.
UML Thumbnail

Approach: Two Pointers

Ask Question

Programming Language
image/screenshot of info(optional)
Full Screen
Loading...

Suggested Answer

Answer
Full Screen
Copy Answer Code
Loading...