Find the minimum operations to balance 0s and 1s after merging two binary strings.
Unlock detailed company stats for this questionUpgrade
Function minOperationsToUnbias(data1, data2) returns an int. Given two binary strings data1 and data2, in one operation you can remove the rightmost character of data1 or the leftmost character of data2. Find the minimum number of operations so that after merging, the total number of 0s equals the total number of 1s. The datasets need not be the same size when merged; the combined dataset must just contain an equal number of 0s and 1s. Example: data1 = "001", data2 = "110" -> 2 (remove both 1s from data2, or the last 1 of data1 and first 1 of data2). Example: data1 = "111000", data2 = "001111" -> 5. Constraints: 1 <= |data1|, |data2| <= 10^5.
Community answers
No answers contributed by the community yet.


