We are given a binary string containing 1’s and 0’s. Find maximum length of consecutive 1’s in it.
Input : str = '11000111101010111' Output : 4
We have existing solution for this problem please refer Maximum consecutive one’s (or zeros) in a binary array link. We can solve this problem within single line of code in Python. Approach is very simple,
- Separate all sub-strings of consecutive 1’s separated by zeros using split() method of string.
- Print maximum length of splited sub-strings of 1’s.
- Return maximum occurring character in an input string
- Print all the duplicates in the input string
- Remove characters from the first string which are present in the second string
- Remove duplicates from a given string
- Print reverse of a string using recursion
- Write a program to print all permutations of a given string
- Divide a string in N equal parts
- Given a string, find its first non-repeating character
- Write a program to reverse an array or string
- Reverse words in a given string
- Run Length Encoding
- Find the smallest window in a string containing all characters of another string
- Length of the longest substring without repeating characters
- Lexicographic rank of a string
- An in-place algorithm for String Transformation
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.