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.
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.
- Split the binary string into substrings with equal number of 0s and 1s
- Remove minimum characters from string to split it into three substrings under given constraints
- Check if a string can be split into even length palindromic substrings
- Check if a string can be split into substrings starting with N followed by N characters
- Split a given string into substrings of length K with equal sum of ASCII values
- Count ways to split a Binary String into three substrings having equal count of zeros
- Split string into three palindromic substrings with earliest possible cuts
- Check if a palindromic string can be obtained by concatenating substrings split from same indices of two given strings
- Split the string into minimum parts such that each part is in the another string
- Minimum number of substrings the given string can be splitted into that satisfy the given conditions
- Minimum flips required to convert given string into concatenation of equal substrings of length K
- Minimize cost to convert given string into concatenation of equal substrings of length K
- Check if given string can be split into four distinct strings
- Split the given string into Primes : Digit DP
- Split the given string into Odds: Digit DP
- Split a binary string into K subsets minimizing sum of products of occurrences of 0 and 1
- Count of ways to split given string into two non-empty palindromes
- Check if a string can be split into two strings with same number of K-frequent characters
- Split a Numeric String into Fibonacci Sequence
- Find all possible ways to Split the given string into Primes
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.