-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathbreedflip.java
More file actions
36 lines (31 loc) · 919 Bytes
/
Copy pathbreedflip.java
File metadata and controls
36 lines (31 loc) · 919 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
import java.util.*;
import java.io.*;
import java.math.*;
public class breedflip {
public static void main(String[] args) throws IOException {
Scanner in = new Scanner(new File("breedflip.in"));
PrintWriter out = new PrintWriter(new BufferedWriter(new FileWriter("breedflip.out")));
int n = in.nextInt();
String s1 = in.next();
String s2 = in.next();
int[] ar = new int[n];
for(int i = 0 ;i<n;i++){
if(s1.charAt(i) == s2.charAt(i)){ar[i] = 0;}
else{ar[i] = 1;}
}
int count = 0;
int toggle = 0;
for(int j : ar){
if(j == 1){
if(toggle == 0){
count++;
toggle = 1;
}
}else{
toggle = 0;
}
}
out.println(count);
out.close();
}
}