Given a sentence, task is to remove spaces from the sentence and rewrite in Snake case. It is a style of writing where we replace spaces with underscore and all words begin with small letters.
Input : I got intern at geeksforgeeks Output : i_got_intern_at_geeksforgeeks Input : Here comes the garden Output : here_comes_the_garden
Simple solution : First method is to traverse sentence and one by one replace spaces by underscores and changing case of first character to small letter. It takes O(n*n) time.
Efficient solution : We traverse given string, while traversing we replace space character with underscore and whenever we encounter non-space letter, we change that letter to small.
Below is the code implementation :
- Check a given sentence for a given set of simple grammer rules
- Lower case to upper case - An interesting fact
- String in Switch Case in Java
- Convert characters of a string to opposite case
- Case conversion (Lower to Upper and Vice Versa) of a string using BitWise operators in C/C++
- Toggle case of a string using Bitwise Operators
- Calculate the difficulty of a sentence
- Permute a string by changing case
- Sentence Palindrome (Palindrome after removing spaces, dots, .. etc)
- Remove all the palindromic words from the given sentence
- Camel case of a given sentence
- Sums of ASCII values of each word in a sentence
- Convert the ASCII value sentence to its equivalent string
- Print given sentence into its equivalent ASCII form
- Java program to swap first and last characters of words in a sentence
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 Improve this article if you find anything incorrect by clicking on the "Improve Article" button below.