Given a binary string str, the task is to find the count of deletion of the sub-string “01” or “10” from the string so that the given string is free from these sub-strings. Print the minimum number of deletions.
Input: str = “11010”
The resultant string will be “1”
Input: str = “1000101”
Resultant string, str = “0”
Approach: We are deleting “01” and “10” and the binary string contains only characters ‘0’ and ‘1’. Therefore, minimum number of deletions will be equal to the minimum of the count of ‘0’ and ‘1’.
Below is the implementation of the above approach:
- Count of operations to make a binary string"ab" free
- Minimum number of deletions to make a string palindrome
- Minimum number of deletions to make a string palindrome | Set 2
- Minimum cost to make a string free of a subsequence
- Minimum deletions from string to reduce it to string with at most 2 unique characters
- Number of flips to make binary string alternate | Set 1
- Minimum swaps required to make a binary string alternating
- Find if it is possible to make a binary string which contanins given number of "0", "1" , "01" and "10" as sub sequences
- Minimum number of replacements to make the binary string alternating | Set 2
- Minimum number of swaps to make two binary string equal
- Minimum swaps required to make a binary string divisible by 2^k
- Minimum number of characters to be removed to make a binary string alternate
- Number of ways to make binary string of length N such that 0s always occur together in groups of size K
- Minimum changes required to make first string substring of second string
- Check if a string can be repeated to make another 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 firstname.lastname@example.org. 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.