Problem
A palindrome is a text that reads the same from left to right and from right to left.
You get a string s. First, change all uppercase letters to lowercase letters. Then remove each character that is not a letter or a digit.
Return true if the result is a palindrome. Return false if it is not. An empty result is a palindrome.
Example 1
- Input:
- s = "Step on no pets!"
- Output:
- true
- Explanation:
- After the two steps, the text is
"steponnopets". It reads the same in both directions.
Example 2
- Input:
- s = "Abc, cbx"
- Output:
- false
- Explanation:
- After the two steps, the text is
"abccbx". The first character isa, but the last character isx.
Example 3
- Input:
- s = " ,. "
- Output:
- true
- Explanation:
- No letters or digits remain. An empty text is a palindrome.
Constraints
- 1 <= s.length <= 2 * 10^5
- s contains only printable ASCII characters.
SysRound wrote this statement. A reference solution checks every example.
Related questions
Continue with questions that share topics or the same question type.
- Count Binary Substrings
Coding · String · Two Pointers
- Find the Index of the First Occurrence in a String
Coding · Boyer–Moore String-Search Algorithm · Knuth–Morris–Pratt Algorithm · String
- Longest Palindromic Substring
Coding · Dynamic Programming · Manacher · String
- Palindromic Substrings
Coding · Dynamic Programming · String · Two Pointers
Sources · 2 references
These records explain where the question appears. A company tag or candidate report does not guarantee a future interview question.
Hello Interview · 2 records
Apple
Leetcode 125. Valid Palindrome
Reported Jun 1, 2026 · 2 source reports
MID_LEVEL
Source snapshot: Nov 12, 2026
View sourceMeta
Leetcode 125. Valid Palindrome
Reported Feb 23, 2026 · 22 source reports
MANAGER, MID_LEVEL, SENIOR, STAFF
Source snapshot: Nov 12, 2026
View source
LeetCode company tags · 4 records
Bloomberg
Valid Palindrome
Reported date not specified · Source window: 6mo
Source snapshot: Oct 20, 2026
Source frequency score: 66.6. This is not an interview probability.
View sourceMeta
Valid Palindrome
Reported date not specified · Source window: 30d