Longest Even Length Substring such that Sum of First and Second Half is same - GeeksforGeeks
Longest Even Length Substring such that Sum of First and Second Half is same Given a string 'str' of digits, find length of the longest substring of 'str', such that the length of the substring is 2k digits and sum of left k digits is equal to the sum of right k digits. Examples: Input: str = "123123" Output: 6 The complete string is of even length and sum of first and second half digits is same Input: str = "1538023" Output: 4 The longest substring with same first and second half sum is "5380" A Simple Solution is to check every substring of even length. The following is C based implementation of simple approach. // A simple C based program to find length of longest even length // substring with same sum of digits in left and right #includeRead full article from Longest Even Length Substring such that Sum of First and Second Half is same - GeeksforGeeks