List of utility methods to do Array Compare
List | getRelativeSegments(String[] targetPath, int commonSegments, int discardedSegments) get Relative Segments List<String> segments = new ArrayList<String>(); for (int j = 0; j < discardedSegments; j++) { segments.add(PARENT); segments.addAll(Arrays.asList(Arrays.copyOfRange(targetPath, commonSegments, targetPath.length))); return segments; |
String | longestCommonPrefix(String[] stringArray) Returns the longest common prefix for the specified strings. return longestCommonPrefix(Arrays.asList(stringArray));
|
List | longestCommonSubsequence(E[] s1, E[] s2) longest Common Subsequence int[][] num = new int[s1.length + 1][s2.length + 1]; for (int i = 1; i <= s1.length; i++) for (int j = 1; j <= s2.length; j++) if (s1[i - 1].equals(s2[j - 1])) num[i][j] = 1 + num[i - 1][j - 1]; else num[i][j] = Math.max(num[i - 1][j], num[i][j - 1]); int s1position = s1.length, s2position = s2.length; ... |
int | longestCommonSubsequenceAlternate(int[] input) longest Common Subsequence Alternate Arrays.sort(input); int curCount = 1; int maxCount = 0; for (int i = 1; i < input.length; i++) { if (input[i] - input[i - 1] == 1) { curCount++; } else { curCount = 1; ... |
String | longestCommonSubstring(String s[]) longest Common Substring if (s.length == 0) return ""; String res = s[0]; for (int i = 1; i < s.length; i++) { while (true) { if (s[i].startsWith(res)) break; if (res.length() == 0) ... |