Find the maximum number of equal-bit pairs in a subsequence of a binary string.
Unlock detailed company stats for this questionUpgrade
Given a binary signal string, choose a subsequence by deleting zero or more characters without changing the order of the remaining characters. Whenever two identical bits appear consecutively in the chosen subsequence (like '00' or '11'), they form an equal-bit pair. Determine the maximum number of equal-bit pairs that can be formed.
Complete getMaxEqualPairs(string signal) -> int. Example: signal = "10101" -> 2 (choose all '1's to form "111", giving pairs at indices 0-1 and 1-2). Sample: input 11011100 -> 5 (subsequence "1111100" yields 5 equal-bit pairs). Constraints: 1 <= length of signal <= 2 * 10^5; the string contains only '0' and '1'.
Format · Amazon SDE Intern OA.
Community answers
No answers contributed by the community yet.
Related questions
Find the maximum length string that is a subsequence of x and a substring of y.Find the maximum even subsequence in an array.Find the maximum substring sum based on the difference between the number of 0s and the number of 1s.Related courses

Course

Course
Course
