Equalize strings
Practice
3.5 (11 votes)
Algorithms
Basics of greedy algorithms
Greedy algorithms
Problem
93% Success 3915 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\)
Submissions
Please login to view your submissions
Similar Problems
Points:20
10 votes
Tags:
Greedy AlgorithmsAlgorithmsBasics of Greedy AlgorithmsGreedy algorithm
Points:10
49 votes
Tags:
Ad-HocVery-EasySimple-math
Points:20
42 votes
Tags:
AlgorithmsApprovedEasyGreedy AlgorithmsMathOpenSorting
Editorial