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 email@example.com. 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.
Attention reader! Don’t stop learning now. Get hold of all the important DSA concepts with the DSA Self Paced Course at a student-friendly price and become industry ready.
- Count palindrome words in a sentence
- Print longest palindrome word in a sentence
- Check if string is palindrome after removing all consecutive duplicates
- 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
- Nth Even length Palindrome
- N'th palindrome of K digits
- Palindrome Partitioning | DP-17
- Double Base Palindrome
- Next smallest prime palindrome
- Check if a number is Palindrome in PL/SQL
- Check if sum of any subarray is Palindrome or not
- Check if a given string is Even-Odd Palindrome or not
- Longest Possible Chunked Palindrome
- Next word that does not contain a palindrome and has characters from first k
- Palindrome by swapping only one character
- Sum of first K even-length Palindrome numbers
- Sum of all N digit palindrome numbers