int (String[] dirs, String[] others) { int matches = 0; for (int i = 0; i < dirs.length && i < others.length; i++) { if (dirs[i].equals(others[i])) { matches = i + 1; } else { break; } } return matches; }