Given a string and a delimiter character. Split the string based on the delimiter and print the list of resulting sub strings.
Input : str = "geeks;for;geeks" d_ch = ';' Output : geeks for geeks Input : str = "##ayush##jauhari####" d_ch = '#' Output : ayush jauhari
splitStrings(str, substr_list, dl) Initialize word = "" Initialize num = 0 str = str + dl l = str.size for i = 0 to l-1 if str[i] != dl word = word + str[i] else if word.size != 0 substr_list[num] = word num++ word = "" return num
This algorithm will fill in the splitted substrings in the array substr_list and will return the number of such substrings as num.
geeks for geeks
Time Complexity: O(n), where n is the length of the given string.
GeeksforGeeks has prepared a complete interview preparation course with premium videos, theory, practice problems, TA support and many more features. Please refer Placement 100 for details
- Split the binary string into substrings with equal number of 0s and 1s
- Replace two substrings (of a string) with each other
- Number of substrings of a string
- Different substrings in a string that start and end with given strings
- Number of even substrings in a string of digits
- Number of substrings of one string present in other
- Count of substrings of a binary string containing K ones
- Program to print all substrings of a given string
- Lexicographical concatenation of all substrings of a string
- Sum of all substrings of a string representing a number | Set 1
- Minimum changes to a string to make all substrings distinct
- Counting even decimal value substrings in a binary string
- Lexicographically all Shortest Palindromic Substrings from a given string
- Reverse the substrings of the given String according to the given Array of indices
- Number of substrings with odd decimal value in a binary 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.