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.
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.
- Removing spaces from a string using Stringstream
- Frequency of smallest character in first sentence less than that of second sentence
- Check if string remains palindrome after removing given number of characters
- Check if string is palindrome after removing all consecutive duplicates
- Count palindrome words in a sentence
- Print longest palindrome word in a sentence
- Find longest palindrome formed by removing or shuffling chars from string
- Character replacement after removing duplicates from a string
- Minimum sum of squares of character counts in a given string after removing k characters
- Subsequence queries after removing substrings
- Print reverse string after removing vowels
- Minimize ASCII values sum after removing all occurrences of one character
- Balance a string after removing extra brackets
- Find the resultant String after replacing X with Y and removing Z
- Reduce the number to minimum multiple of 4 after removing the digits
- Print string after removing all (“10” or “01”) from the binary string
- Maximum non-repeating characters after removing K characters
- Print all possible strings that can be made by placing spaces
- Remove spaces from a given string
- Remove extra spaces from a string