Football
6:41AM 05-11-23unknown
plain_text
10 months ago
1.3 kB
3
Indexable
Never
import java.util.*; public class helloWorld{ public static void main(String[] args){ String inp; Scanner sc = new Scanner(System.in); inp = sc.next(); int length = inp.length(); String[] indvBits = new String[length]; for (int i = 0; i < length; i++) { indvBits[i] = inp.substring(i, i + 1); } int ZeroMax = 0, OneMax = 0; int zeroCurrent = 0, oneCurrent = 0; for (int i = 0; i < length; i++) { if(indvBits[i].equals("0")){ if(OneMax < oneCurrent){ OneMax = oneCurrent; } oneCurrent = 0; zeroCurrent++; continue; } else if(indvBits[i].equals("1")){ if(ZeroMax < zeroCurrent){ ZeroMax = zeroCurrent; } zeroCurrent = 0; oneCurrent++; continue; } }