Write a program to check if a sentence is palindrome or not. You can ignore white spaces and other characters to consider sentence as a palindrome.
Input : str = "Too hot to hoot." Output : Sentence is palindrome. Input : str = "Abc def ghi jklm." Output : Sentence is not palindrome.
Note that there may be multiple spaces and/or dots between two words.
To find if a sentence is palindrome, compare each character from left and right. If they are equal, compare until left and right of string are equal or right becomes less then left. Remember to ignore white spaces and other characters in a string.
Sentence is palindrome.
This article is contributed by nuclode. If you like GeeksforGeeks and would like to contribute, you can also write an article using contribute.geeksforgeeks.org or mail your article to firstname.lastname@example.org. See your article appearing on the GeeksforGeeks main page and help other Geeks.
Please write comments if you find anything incorrect, or you want to share more information about the topic discussed above.
- Count palindrome words in a sentence
- Print longest palindrome word in a sentence
- Check if string remains palindrome after removing given number of characters
- Find longest palindrome formed by removing or shuffling chars from string
- Count all palindrome which is square of a palindrome
- Removing spaces from a string using Stringstream
- N'th palindrome of K digits
- Nth Even length Palindrome
- Palindrome Partitioning | DP-17
- Sum of first K even-length Palindrome numbers
- Double Base Palindrome
- Palindrome by swapping only one character
- Next word that does not contain a palindrome and has characters from first k
- Check if the sum of digits of N is palindrome
- Sum of all N digit palindrome numbers