Перейти к содержимому

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

Becoming A Better Dev (with David)

0:00 / 0:00

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

1 986 просмотров · 5 лет назад
Becoming A Better Dev (with David)
2,58 тыс. подписчиков
1 986 просмотров · 5 лет назад
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. https://calendly.com/anusontarangkul/... Let's Connect 💯: ════════════════════════════ LinkedIn:   / anusontarangkul   TikTok:   / david.anu_   Instagram:   / david.anu_   GitHub: https://github.com/anusontarangkul