FastPrepPalindrome Check Ignoring Symbols
Problems/Palindrome Check Ignoring Symbols

Palindrome Check Ignoring Symbols

Walmart logoWalmart● EasyFULLTIMEONSITE INTERVIEW
QuestionFunctionExamplesConstraints

Problem statement

Source note: At a Walmart onsite for a full-time software engineer role, the second task of one round was to check whether a string is a palindrome after skipping symbols and spaces, using two pointers.

The report does not say whether case matters, whether digits count, or what to return when nothing is left. Practice choices here: letters and digits are compared and every other character is skipped; uppercase and lowercase letters count as the same; a string with no letter or digit counts as a palindrome; the input is printable ASCII. The signature, limits and examples are ours.

The judged task matches the report at about 85%.

You are given a string s. Decide whether it reads the same forwards and backwards when you look only at its letters and digits.

Skip every other character, such as spaces and punctuation, and treat uppercase and lowercase forms of a letter as the same. If no letter or digit is left, the answer is true.

Return true if s is a palindrome by this rule, and false otherwise.

Function

isPalindrome(s: String) → boolean

Examples

Example 1

s = "Step on no pets!"return = true

Keeping letters only and ignoring case gives steponnopets, which reads the same backwards.

Example 2

s = "Ab2,b-A1"return = false

The kept characters are ab2ba1. Digits count, so the final 1 breaks the match with the first a.

Example 3

s = "?! ."return = true

No letter or digit is left, and an empty sequence is a palindrome.

Constraints

  • 1 <= s.length <= 2 * 10^4
  • s contains only printable ASCII characters (codes 32 to 126), including spaces.

More Walmart problems

  • Merge a List In Between Two PositionsONSITE INTERVIEW · Seen Nov 2026
  • Merge Intervals from Start and End ListsONSITE INTERVIEW · Seen Nov 2026
  • Largest Team Where Every Pair OverlapsOA · Seen Nov 2026
All Walmart interview questionsSee Walmart hiring insights
Saved
class Solution {
    public boolean isPalindrome(String s) {
        // Write your code here.
    }
}
Checking account…