Commit 05c491f0 authored by Ilya Prokhorov's avatar Ilya Prokhorov

SuffexArray rename

parent ae94c8df
import kotlin.math.min
fun main(args: Array<String>) {
val searchString = "adasDATAHEADER??jpjjwerthhkjbcvkDATAHEADER??kkasdf"
val searchString = "adasDATAHEADER??"
searchLongestRepeatedSubstring(searchString)
}
......@@ -18,7 +18,7 @@ fun longestPrefix(lhs: String, rhs: String): String {
}
fun searchLongestRepeatedSubstring(searchString: String): String {
val suffixTree = suffixTree(searchString)
val suffixTree = suffixArray(searchString)
val sortedSuffixTree = suffixTree.sorted()
var longestRepeatedSubstring = ""
......@@ -33,11 +33,11 @@ fun searchLongestRepeatedSubstring(searchString: String): String {
return longestRepeatedSubstring
}
fun suffixTree(string: String): Array<String> {
var suffixTree = ArrayList<String>()
fun suffixArray(string: String): Array<String> {
var suffixArray = ArrayList<String>()
for (i in 0..string.length - 1) {
val substring = string.substring(i)
suffixTree.add(substring)
suffixArray.add(substring)
}
return suffixTree.toTypedArray()
return suffixArray.toTypedArray()
}
\ No newline at end of file
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment