Exercise · Strings and Arrays · lesson 5 of 6
Exercise: palindrome
Write a function bool is_palindrome(std::string_view s). It returns true if s is a palindrome, and false otherwise. A palindrome reads the same from left to right and from right to left.
is_palindrome("abba")→trueis_palindrome("level")→trueis_palindrome("abca")→false
Constraints: letter case matters, so "Abba" is not a palindrome; an empty string and a one-character string are palindromes.
Do not add extra #include lines unless the task says so explicitly.
Subscribe to take the course
The course is free. Sign in with Telegram and subscribe to the channel to open every lesson.