Files
2026-02-11 14:56:22 +05:30

6 lines
297 B
Markdown

Time complexity : O(n*m) where is n is the number of strings in the list and m is length of the shortest string
space complexity : O(1)
We start from first character of first string and compare it with all other strings, if no mismatch then add it to prefix string else return the prefix string