Company: Walmart
Difficulty: medium
Longest Good Subsequence Problem Description A **subsequence** of a string is obtained by removing zero or more characters from it without changing the order of the remaining characters. A subsequence is called **good** when all of the following hold: its length `m` is positive and even; its first `m / 2` characters are all equal to one another; its last `m / 2` characters are all equal to one another. The character used in the first half and the character used in the second half may be the same or different. For example, `"2222"` and `"333444"` are good, while `"222"` and `"234234"` are not good *themselves*, although each of them still contains a shorter good subsequence. Given a string `s`, return the length of the longest good subsequence of `s`. Return `0` when `s` has no good subsequence at all. Input Format A single line containing the string `s`. Output Format Print a single integer: the length of the longest good subsequence of `s`, or `