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 the first and last character of each word in a String
- Capitalize the first and last character of each word in a string
- Print last character of each word in a string
- Reverse every word of the string except the first and the last character
- Remove the first and last occurrence of a given Character from a String
- Remove first and last character of a string in Java
- Modify string by increasing each character by its distance from the end of the word
- Get the first letter of each word in a string using regex in Java
- Find the player who is the last to remove any character from the beginning of a Binary String
- How to find the first and last character of a string in Java
- Swap the first and last character of a string in Java
- C program to find and replace a word in a File by another given word
- Minimum operation require to make first and last character same
- Length Of Last Word in a String
- 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
- Longest Common Prefix using Word by Word Matching
- C program to Replace a word in a text by another given word
- Find the word from a given sentence having given word as prefix
- Queries to find the last non-repeating character in the sub-string 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.