#C9849. Longest Common Directory Path

    ID: 53987 Type: Default 1000ms 256MiB

Longest Common Directory Path

Longest Common Directory Path

Given a list of absolute Unix-style directory paths, your task is to find the longest common prefix that forms a valid directory path. In other words, determine the deepest directory that is common to all the given paths.

Note: The paths are provided in Unix format, where directories are separated by the character /. If there is no common directory path, output an empty string.

For example, for the paths: ( /home/user/project,
/home/user/docs,
/home/user/project/src ) The longest common directory path is ( /home/user ).

inputFormat

The first line contains a single integer ( n ) representing the number of directory paths. Each of the next ( n ) lines contains one non-empty Unix-style absolute path.

outputFormat

Output a single line containing the longest common directory path that is valid. If no common directory exists, output an empty string.## sample

3
/home/user/project
/home/user/docs
/home/user/project/src
/home/user

</p>