← Back to companies
[ OK ] Loaded —
[ INFO ]
$ cd
$ ls -lt
01
02
03
04
05
$ ls -lt
01
02
03
04
05
user@intervues:~/$
You are given a list of strings.
A string is considered a prefix string if it is a prefix of any other string in the list. Your task is to remove all prefix strings while preserving the order of strings in the input.
Input: A list of strings, input_list.
Output: A list of strings, output_list, containing only the strings that are not prefixes of any other strings in the input. The output list must preserve the order of strings from the input.
Example 1:
Input: ["a", "ab", "abc"] Output: ["abc"]
Example 2:
Input: ["a", "bc", "ab", "abc hello"] Output: ["bc", "abc hello"]
Note: order must be preserved (e.g., returning ["abc hello", "bc"] is incorrect).
Follow-up: