Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- String nazwiskoJas = fileInput.nextLine();
- String nazwiskoMal = fileInput.nextLine();
- ArrayList<Character> jas = new ArrayList();
- ArrayList<Character> mal = new ArrayList();
- for(int i=0;i<charNumber;i++) {
- jas.add(nazwiskoJas.charAt(i));
- mal.add(nazwiskoMal.charAt(i));
- }
- fileInput.close();
- int steps=0;
- int index=0;
- while(jas.size()>1) {
- if(jas.get(0)!=mal.get(index)) {
- int distance = jas.indexOf(mal.get(index));
- jas.remove(distance);
- steps+=distance;
- }else {
- jas.remove(0);
- }
- index++;
- }
- System.out.println(steps);
Add Comment
Please, Sign In to add comment