You are viewing a single comment's thread. Return to all comments →
Kotlin solution
fun commonChild(s1: String, s2: String): Int { val table = Array<Array<Int>>(s2.length + 1){Array<Int>(s1.length + 1){0}} for (i in 1..s1.length) { for(j in 1..s2.length) { table[i][j] = if (s1[i-1] == s2[j-1]) 1 + table[i-1][j-1] else Math.max(table[i][j-1], table[i-1][j]) } } return(table[s1.length][s2.length]) }
Seems like cookies are disabled on this browser, please enable them to open this website
Common Child
You are viewing a single comment's thread. Return to all comments →
Kotlin solution