Data update
This commit is contained in:
parent
52a6ef48dd
commit
157b70a810
604 changed files with 14253 additions and 2100 deletions
|
|
@ -1,5 +1,4 @@
|
|||
fn main()
|
||||
{
|
||||
fn main() {
|
||||
println(lcs("thisisatest", "testing123testing"))
|
||||
}
|
||||
|
||||
|
|
@ -7,11 +6,11 @@ fn lcs(a string, b string) string {
|
|||
mut lengths := map[int]int{}
|
||||
mut output :=''
|
||||
mut greatest_length := 0
|
||||
|
||||
for i, x in a {
|
||||
for j, y in b {
|
||||
if x == y {
|
||||
if i == 0 || j == 0 {lengths[i * b.len + j] = 1} else {lengths[i * b.len + j] = lengths[(i-1) * b.len + j-1] + 1}
|
||||
if i == 0 || j == 0 {lengths[i * b.len + j] = 1}
|
||||
else {lengths[i * b.len + j] = lengths[(i-1) * b.len + j-1] + 1}
|
||||
if lengths[i * b.len + j] > greatest_length {
|
||||
greatest_length = lengths[i * b.len + j]
|
||||
output += x.ascii_str()
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue