The TransCompilator

Solved LeetCode program · 810 of 1,000

#1048 · Longest String Chain

Medium Array chunk-17.md

Original English source

The words is a list of "a", "b", "ba", "bca", "bda", and "bdca". The count is 6. The last is count minus 1.
For every left from 0 to last.
For every right from left plus 1 to last.
The first is item left of words. The second is item right of words. The firstsize is the number of characters in first. The secondsize is the number of characters in second. If secondsize is less than firstsize, swap item left of words and item right of words.

The best is a list of 6 zeros.
For every spot from 0 to last.
Set item spot of best to 1.

For every right from 0 to last.
For every left from 0 to right minus 1.
The shortraw is item left of words. The longraw is item right of words. The short is empty text. Place shortraw into short. The long is empty text. Place longraw into long. The shortsize is the number of characters in short. The longsize is the number of characters in long. The longlast is the last position of long. The paired is 0.
For every cut from 0 to longlast.
The leftpart is the slice of long from 0 to cut. The rightpart is the slice of long from cut plus 1 to longlast plus 1. The joined is a copy of leftpart. Place rightpart into joined. If joined matches short, set paired to 1. If paired is 1 and item left of best plus 1 is more than item right of best, set item right of best to item left of best plus 1. If paired is 1, stop.

The answer is 0.
For each value in best.
If value is more than answer, set answer to value.

Show answer.

Open in Playground Browse all 1,000 problems

Expected stdout

4