I've got a list fo paths, and I'd like to keep only the items that are not prefix of any other item.
For example, In the following list:
private
private/etc
private/etc/pam.d
usr
usr/local
usr/local/lib
usr/local/lib/security
I want to keep only:
private/etc/pam.d
usr/local/lib/security
I prefer not to "invent the wheel" and implement prefix tree, but using a python package that already do this.
thanks!
If your list is already ordered, each item is a prefix of the following OR is not a prefix of any of the following.
Therefore, you can write:
Another implementation, using zip: