@Test public void testTwo() { String test = "bananabanana"; String answer = lrs.LRS(test); String expected = "banana"; assertTrue(answer.equals(expected)); }
public String LRS(String query) { String[] suffixes = new String[query.length()]; for(int i = 0; i < query.length(); i++) { suffixes[i] = query.substring(i); } Arrays.sort(suffixes); Pair answer = new Pair(); answer.count = 0; for(int i = 0; i < suffixes.length - 1; i++) { Pair candidate = lcp(suffixes[i], suffixes[i + 1]); if(candidate.count > answer.count) answer = candidate; } return answer.value; }
LRS { public String LRS(String query) { String[] suffixes = new String[query.length()]; for(int i = 0; i < query.length(); i++) { suffixes[i] = query.substring(i); } Arrays.sort(suffixes); Pair answer = new Pair(); answer.count = 0; for(int i = 0; i < suffixes.length - 1; i++) { Pair candidate = lcp(suffixes[i], suffixes[i + 1]); if(candidate.count > answer.count) answer = candidate; } return answer.value; } }
LRS { public String LRS(String query) { String[] suffixes = new String[query.length()]; for(int i = 0; i < query.length(); i++) { suffixes[i] = query.substring(i); } Arrays.sort(suffixes); Pair answer = new Pair(); answer.count = 0; for(int i = 0; i < suffixes.length - 1; i++) { Pair candidate = lcp(suffixes[i], suffixes[i + 1]); if(candidate.count > answer.count) answer = candidate; } return answer.value; }  }
LRS { public String LRS(String query) { String[] suffixes = new String[query.length()]; for(int i = 0; i < query.length(); i++) { suffixes[i] = query.substring(i); } Arrays.sort(suffixes); Pair answer = new Pair(); answer.count = 0; for(int i = 0; i < suffixes.length - 1; i++) { Pair candidate = lcp(suffixes[i], suffixes[i + 1]); if(candidate.count > answer.count) answer = candidate; } return answer.value; }  String LRS(String query); }
LRS { public String LRS(String query) { String[] suffixes = new String[query.length()]; for(int i = 0; i < query.length(); i++) { suffixes[i] = query.substring(i); } Arrays.sort(suffixes); Pair answer = new Pair(); answer.count = 0; for(int i = 0; i < suffixes.length - 1; i++) { Pair candidate = lcp(suffixes[i], suffixes[i + 1]); if(candidate.count > answer.count) answer = candidate; } return answer.value; }  String LRS(String query);  }