void (IntList subLines1, IntList subLines2) { int n = Math.max(subLines1.size(), subLines2.size()); boolean skipAligning = n > 10 || // we use brute-force algorithm (C_n_k). This will limit search space by ~250 cases. subLines1.size() == subLines2.size(); // nothing to do if (skipAligning) { int count = Math.min(subLines1.size(), subLines2.size()); for (int i = 0; i < count; i++) { int index1 = subLines1.getInt(i); int index2 = subLines2.getInt(i); if (lines1.get(index1).equals(lines2.get(index2))) { builder.markEqual(index1, index2); } } return; } if (subLines1.size() < subLines2.size()) { int[] matching = getBestMatchingAlignment(subLines1, subLines2, lines1, lines2); for (int i = 0; i < subLines1.size(); i++) { int index1 = subLines1.getInt(i); int index2 = subLines2.getInt(matching[i]); if (lines1.get(index1).equals(lines2.get(index2))) { builder.markEqual(index1, index2); } } } else { int[] matching = getBestMatchingAlignment(subLines2, subLines1, lines2, lines1); for (int i = 0; i < subLines2.size(); i++) { int index1 = subLines1.getInt(matching[i]); int index2 = subLines2.getInt(i); if (lines1.get(index1).equals(lines2.get(index2))) { builder.markEqual(index1, index2); } } } }