Equalize strings
Practice
3.5 (11 votes)
Algorithms
Basics of greedy algorithms
Greedy algorithms
Problem
93% Success 3916 Attempts 20 Points 1s Time Limit 256MB Memory 1024 KB Max Code
You are given two binary strings \(S\) and \(T\) of the same length \(N\). Your task is to make both the strings equal. Perform the following operation on string \(S\):
Select any substring of \(S\) then flip all 1's to 0 and flip all 0's to 1 of that substring.
Print the minimum number of operations you have to perform to make them equal.
Input format
- The first line contains a single integer \(N\) (\(1\le N\le 1e5\)) size of each string
- The second line contains a string \(S\) of length \(N\).
- The third line contains a string \(T\) of length \(N\).
Output format
Print a single integer denoting the minimum number of operations required to make both the strings equal.
Constraints
\(1\le N\le 1e5\)
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
Results
Custom Input
Run your code to see the output
Submissions
Please login to view your submissions
Similar Problems
Points:20
191 votes
Tags:
ReadyApprovedEasyProbability and Statistics
Points:20
105 votes
Tags:
ApprovedBasic ProgrammingBrute-force searchEasyReady
Points:20
7 votes
Tags:
AlgorithmsBasics of Greedy AlgorithmsC++Greedy Algorithms
Editorial
Login to unlock the editorial