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

Sep 8, 2020
1 min read

Updated: Sep 10, 2020


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++


1 Comment


https://applepaycasino24.de is where my mind wandered when the post mentioned returning 0 or 1, since that binary simplicity feels a lot like the win-or-lose logic in games. The part about skipping special characters and ignoring case is the detail I always trip over in interviews, because it's easy to forget the two-pointer check breaks the moment you compare raw characters. I've started cleaning the string first and then comparing, which sounds obvious but has saved me more than once.

Like
bottom of page