Check if a String is a Palindrome
viaGlassdoor
Problem: Write a program to check whether a given string is a palindrome (reads the same forwards and backwards).
Constraints: String may contain only alphanumeric characters, or may need case-insensitive/whitespace-agnostic handling depending on follow-up.
Example: "madam" -> true, "hello" -> false.
Approach: Use two pointers starting at both ends of the string, moving inward and comparing characters at each step; return false on the first mismatch, true if the pointers cross without a mismatch. O(n) time, O(1) extra space.
asked …