Guest User

Untitled

a guest
Apr 19th, 2018
112
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.61 KB | None | 0 0
  1. String nazwiskoJas = fileInput.nextLine();
  2. String nazwiskoMal = fileInput.nextLine();
  3. ArrayList<Character> jas = new ArrayList();
  4. ArrayList<Character> mal = new ArrayList();
  5.  
  6.  
  7.  
  8. for(int i=0;i<charNumber;i++) {
  9. jas.add(nazwiskoJas.charAt(i));
  10. mal.add(nazwiskoMal.charAt(i));
  11. }
  12.  
  13. fileInput.close();
  14.  
  15. int steps=0;
  16. int index=0;
  17. while(jas.size()>1) {
  18.  
  19. if(jas.get(0)!=mal.get(index)) {
  20.  
  21. int distance = jas.indexOf(mal.get(index));
  22. jas.remove(distance);
  23. steps+=distance;
  24.  
  25. }else {
  26. jas.remove(0);
  27. }
  28. index++;
  29. }
  30.  
  31.  
  32. System.out.println(steps);
Add Comment
Please, Sign In to add comment