Posted on

Description

This is the second problem. Basically about the largest substring.

My Submission

import math

T = int(input())

for i in range(T):
    N = int(input())
    half_length = math.ceil(N / 2)
    S = input()
    total = 0
    for c in S[0:half_length]:
        total += int(c)
    largest = total
    for j in range(N - half_length):
        total += (int(S[half_length + j]) - int(S[j]))
        if total > largest:
            largest = total
            
    print("Case #{}: {}".format(i + 1, largest))

Accepted

Leave a Reply

Your email address will not be published. Required fields are marked *