Given the string the task is to remove the first and last character of each word in a string.
Input: Geeks for geeks Output: eek o eek Input: Geeksforgeeks is best Output: eeksforgeek es
- Split the String based on the space
- Run a loop from the first letter to the last letter.
- Check if the character is the starting or end of the word
- Remove this character from the String.
Below is the implementation of the above approach.
Geeks for Geeks eek o eek
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.
- Print last character of each word in a string
- Print the first and last character of each word in a String
- Capitalize the first and last character of each word in a string
- Reverse every word of the string except the first and the last character
- Remove all occurrences of a character in a string
- Remove the first and last occurrence of a given Character from a String
- Remove first and last character of a string in Java
- Remove a character from a string to make it a palindrome
- Remove all occurrences of a character in a string | Recursive approach
- Modify the string such that every character gets replaced with the next character in the keyboard
- Replace every character of string by character whose ASCII value is K times more than it
- Find a string such that every character is lexicographically greater than its immediate next character
- Check if frequency of character in one string is a factor or multiple of frequency of same character in other string
- Replace all occurrences of character X with character Y in given string
- Map every character of one string to another such that all occurrences are mapped to the same character
- String containing first letter of every word in a given string with spaces
- Most frequent word in first String which is not present in second String
- Replace every character of a string by a different character
- Lexicographically smallest string formed by appending a character from first K characters of a string | Set 2
- Lexicographically smallest string formed by appending a character from the first K characters of a given string
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.