All challenges
Easy 0 solved 0% acceptance

Palindrome String

Check whether text reads the same forwards and backwards.

Problem

Decide whether text is a palindrome, considering only letters and digits and ignoring case.

Implement is_palindrome(text).

Input

text: The text to check (ASCII characters).

Output

Return true for a palindrome, otherwise false.

Constraints

0 ≤ length ≤ 10,000

Examples

Example 1
Input:
text = "Racecar"

Expected output:
expected = True
Input:
std::string text = "Racecar";

Expected output:
bool expected = true;
Input:
string text = "Racecar";

Expected output:
bool expected = true;

Explanation

Lowercased, "racecar" reads the same both ways.

Example 2
Input:
text = "hello"

Expected output:
expected = False
Input:
std::string text = "hello";

Expected output:
bool expected = false;
Input:
string text = "hello";

Expected output:
bool expected = false;

Explanation

"hello" backwards is "olleh", which is different.

References

This challenge is adapted for CodeUtility. Follow the statement and constraints above.

Learn from others

Community solutions

No published solutions yet. Solve this challenge to share the first one.