Description
Solutions
Reverse Binary String with Minimum Shifts
π©βπ NEW GRADπRELATED PROBLEMS
You are given a binary string. Find the minimum number of operations required to reverse it. An operation is defined as: Remove a character from any index and append it to the end of the string.
Function Description
Complete the function reverseBinaryString
in the editor.
reverseBinaryString
has the following parameter:
String s
: a binary string
Returns
int
: the minimum number of operations required to reverse the binary string
Example 1:
Input: s = "00110101"
Output: 3
Explanation:Here is one way to reverse the string in 3 operations:00110101 - 00101011 (index 3 was appended at the end) 00101011 - 01010110 (index 0 was appended at the end) 01010110 - 10101100 (index 0 was appended at the end) So the answer here is 3 operations.
Constraints:
1 β€ S.length β€ 1e5

Related Problems
Testcase
Result
Case 1
input:
output: