Skip to content
Justice Tech School

Practice: Palindrome

Compare a string with its reverse.

Example
#include <iostream>
#include <string>

int main() {
  std::string s = "level";
  std::string r(s.rbegin(), s.rend());
  std::cout << (s == r ? "palindrome" : "no") << "\n";
  return 0;
}

Result

palindrome

Exercise

Reverse iterator.

s.()

Quiz Test

What is rbegin?

These free lessons are for learning. Join a full course for projects, mentor feedback and a verified certificate.