The TransCompilator

Solved LeetCode program · 14 of 1,000

#0014 · Longest Common Prefix

Easy Array chunk-01.md

Original English source

The words is a list of "flower", "flow", and "flight". The reference is item 0 of words. The limit is the number of characters in reference.
For each word in words.
The size is the number of characters in word. If size is less than limit, set limit to size.

The count is the number of items in words. The prefix is empty text. The last is limit minus 1.
For every position from 0 to last.
The matches is 0. For each word in words, if character position of word is character position of reference, add 1 to matches. If matches is count, Place character position of reference into prefix, otherwise stop.

Report prefix.

Open in Playground Browse all 1,000 problems

Expected stdout

fl