/**
 * Given two strings, find the longest common substring.
 *
 * @param s1 The first string.
 * @param s2 The second string.
 * @return The longest common substring.
 */
fun longestSubstring(s1: String, s2: String): String {

    var longest = ""
    for (i in s1.indices) {
        for (j in s2.indices) {
            if (s1[i] == s2[j]) {
                var length = 1
                var subStr = s1[i].toString()
                var p = i + 1
                var q = j + 1

                while (p < s1.length && q < s2.length && s1[p] == s2[q]) {
                    subStr += s1[p]
                    p++
                    q++
                    length++
                }

                if (length > longest.length) {
                    longest = subStr
                }
            }
        }
    }
    return longest
}
/**
 * Given two strings, find the longest common substring.
 *
 * @param s1 The first string.
 * @param s2 The second string.
 * @return The longest common substring.
 */
fun longestSubstring(s1: String, s2: String): String {
/**
 * Given two strings, find the longest common substring.
 *
 * @param s1 The first string.
 * @param s2 The second string.
 * @return The longest common substring.
 */
fun longestSubstring(s1: String, s2: String): String {

    var longest = ""
    for (i in s1.indices) {
        for (j in s2.indices) {
            if (s1[i] == s2[j]) {
                var length = 1
                var subStr = s1[i].toString()
                var p = i + 1
                var q = j + 1

                while (p < s1.length && q < s2.length && s1[p] == s2[q]) {
                    subStr += s1[p]
                    p++
                    q++
                    length++
                }

                if (length > longest.length) {
                    longest = subStr
                }
            }
        }
    }
    return longest
}