-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathSwayamvar
More file actions
54 lines (49 loc) · 1.33 KB
/
Copy pathSwayamvar
File metadata and controls
54 lines (49 loc) · 1.33 KB
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
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
//This is The Coding Area
import java.util.*;
import java.lang.*;
import java.io.*;
class Swayamvar{
public static void main(String[] args){
try{
BufferedReader inp = new BufferedReader (new InputStreamReader(System.in));
int N= Integer.parseInt(inp.readLine());
String bride = inp.readLine();
String groom = inp.readLine();
List<Character> brides = convertStringToCharList(bride);
List<Character> grooms = convertStringToCharList(groom);
int i =0,count =0;
while(i<brides.size())
{
int j=0;
while(j<grooms.size()){
boolean res = brides.get(i).equals(grooms.get(0));
if(res){
count++;
grooms.remove(0);
break;
}
else if(res == false){
Collections.rotate(grooms, 1);
j++;
}
}
i++;
if(i>count)
break;
}
System.out.print(N-count);
}
catch(Exception e){
return;
}
}
public static List<Character>
convertStringToCharList(String str)
{
List<Character> chars = new ArrayList<>();
for (char ch : str.toCharArray()) {
chars.add(ch);
}
return chars;
}
}