Palindrome String InterviewBit Solution

Problem: Palindrome String

Problem Description:

Given a string, determine if it is a palindrome, considering only alphanumeric characters and ignoring cases.


"A man, a plan, a canal: Panama" is a palindrome.
"race a car" is not a palindrome.

Return 0 / 1 ( 0 for false, 1 for true ) for this problem.


For the given problem, we have to convert the string into either upper case or lower case.

After that, we will omit the special characters and will consider only those characters containing which are either alphabets or digits.

Then we can compare the generated string with its reverse form if both strings are equal then the given string is a palindrome, otherwise not.

Time & Space Complexity:

Time Complexity: O(N) // As we are only traversing the string
Space Complexity: O(1)


Code in C++