How to Solve 'Valid Palindrome' on LeetCode? (JavaScript Algorithm Problem)

preview_player
Показать описание
This is a classic algorithm problem that we will be solving today.

Language: Javascript
Difficulty: Easy
Strategy: Pointers

Pseudo Code:
1. Use Regex to get get rid of special characters.
2. Create variable for left index to keep track of left pointer to increment.
3. Create variable for right index to keep track of right pointer to decrement.
4. Create while loop to iterate through string (until each pointer meets).
a. Create condition to see if letters of each pointer don't equal to each other. Return false.
b. Increment left pointer.
c. Decrement right pointer.
4. Return true (loop through string without returning false.)

Time Complexity: O(n): loop
Space Complexity: O(1): pointers variable

Do you need more help with coding?
════════════════════════════
✅ Schedule a FREE 30 minute tutoring session with me.

Let's Connect 💯:
════════════════════════════
Рекомендации по теме
Комментарии
Автор

great video David, I'm training with leetcode, and this video helped me a lot

nicolasteofilo