
Problem
Solution
Submissions
Palindrome Check
Certification: Basic Level
Accuracy: 69.44%
Submissions: 36
Points: 5
Write a Java program to implement the isPalindrome(String s) function, which checks if a string is a palindrome by considering only alphanumeric characters and ignoring case.
Example 1
- Input: s = "A man, a plan, a canal: Panama"
- Output: true
- Explanation:
- Cleaned string = "amanaplanacanalpanama"
- Same forwards and backwards → true
Example 2
- Input: s = "race a car"
- Output: false
- Explanation:
- Cleaned string = "raceacar"
- Reverse = "racaecar" → not same → false
Constraints
- 1 ≤ s.length ≤ 2 * 10^5
- The string consists of ASCII characters
- Time Complexity: O(n)
- Space Complexity: O(1)
Editorial
My Submissions
All Solutions
Lang | Status | Date | Code |
---|---|---|---|
You do not have any submissions for this problem. |
User | Lang | Status | Date | Code |
---|---|---|---|---|
No submissions found. |
Solution Hints
- Clean the string by removing non-alphanumeric characters and converting to lowercase
- Use two pointers, one at the start and one at the end of the cleaned string
- Compare characters at both pointers
- Move the pointers toward the center
- If any characters don't match, the string is not a palindrome