Already among the first few solutions I looked at, I found some mistakes missed by the current test cases.
This fails `longest_prefix(['aa', 'ba'])`, returning `'a'` instead of `''`.
This fails `longest_prefix(['a', 'ba'])`, returning `'a'` instead of `''`.
This fails `longest_prefix(['aa', 'ba'])`, returning `'a'` instead of `''`.
Btw, the initial code contains this example call:
print(longest_prefix(["flower", "flow", "flight"]))
When I modify the array so there's no common prefix, it looks like nothing gets printed. I suggest to add `repr` for clarity, so `''` gets printed.
print(repr(longest_prefix(["flower", "flow", "flight"])))
And now I'm hoping all my markdown works... It doesn't in the preview, code parts aren't styled as code... (Edit: I see... Backticks aren't supported at all, and only code blocks are supported by indenting, inline code isn't supported at all? Sigh.)
@freeman_lex
Created at: 2024/03/28 22:21; Updated at: 2024/03/29 18:00