/**
 * This function takes two strings as input and finds the longest common subsequence between them.
 *
 * @param str1 The first input string.
 * @param str2 The second input string.
 * @return The longest common subsequence between the two input strings.
 *
 * Example:
 * findCommonSubstr("geology", "biology") returns "ology"
 */
fun findCommonSubstr(str1: String, str2: String): String {

    var maxLength = -1
    var commonSubstr = ""

    var i = 0
    while (i < str1.length) {
        var j = 0
        while (j < str2.length) {
            var k = 1
            while ((i + k) <= str1.length && (j + k) <= str2.length) {
                if (str1.substring(i, i + k) == str2.substring(j, j + k) && k > maxLength) {
                    maxLength = k
                    commonSubstr = str1.substring(i, i + k)
                }
                k++
            }
            j++
        }
        i++
    }

    return commonSubstr
}
/**
 * This function takes two strings as input and finds the longest common subsequence between them.
 *
 * @param str1 The first input string.
 * @param str2 The second input string.
 * @return The longest common subsequence between the two input strings.
 *
 * Example:
 * findCommonSubstr("geology", "biology") returns "ology"
 */
fun findCommonSubstr(str1: String, str2: String): String {
/**
 * This function takes two strings as input and finds the longest common subsequence between them.
 *
 * @param str1 The first input string.
 * @param str2 The second input string.
 * @return The longest common subsequence between the two input strings.
 *
 * Example:
 * findCommonSubstr("geology", "biology") returns "ology"
 */
fun findCommonSubstr(str1: String, str2: String): String {

    var maxLength = -1
    var commonSubstr = ""

    var i = 0
    while (i < str1.length) {
        var j = 0
        while (j < str2.length) {
            var k = 1
            while ((i + k) <= str1.length && (j + k) <= str2.length) {
                if (str1.substring(i, i + k) == str2.substring(j, j + k) && k > maxLength) {
                    maxLength = k
                    commonSubstr = str1.substring(i, i + k)
                }
                k++
            }
            j++
        }
        i++
    }

    return commonSubstr
}