Binary Swap
Practice
3.5 (16 votes)
Algorithms
Easy
String manipulation
Problem
92% Success 6767 Attempts 20 Points 1s Time Limit 256MB Memory 1024 KB Max Code

You are given two binary strings A and B of equal length. You have a type of opertion in which you can swap any two elements of string B. Your task is to find the minimum number of operations required to convert string B into string A. If it is not possible, print -1.

Input Format:

First line contains string A.

Second line contains string B.

Output Format:

Print the minimum number of operations required to convert string B into string A. If it is not possible, print -1.

Constraints:

\(|A| = |B| ; |S| \; refers \; to \; length \; of \; string \; S\)

\(1 \le |A| \le 10^5\)

Please login to use the editor

You need to be logged in to access the code editor

Loading...

Please wait while we load the editor

Loading...
Results
Custom Input
Run your code to see the output
Submissions
Please login to view your submissions
Similar Problems
Points:20
30 votes
Tags:
AlgorithmsEasyString Manipulation
Points:20
642 votes
Tags:
Ad-HocEasyOpenString Manipulation
Points:20
84 votes
Tags:
ApprovedEasyOpen