top of page

Looking to master object-oriented and system design for tech interviews or career growth?

  • Improve your system design and machine coding skills.

  • Study with our helpful resources.

  • Prepare for technical interviews and advance your career.

**We're in beta mode and would love to hear your feedback.

Palindrome String InterviewBit Solution


Problem Description:

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


Example:

"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.



Approach:


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)

Solution:

Code in C++


bottom of page