Longest common suffix

Write codeEasy12 min

Your task

A build tool groups artifacts by shared name endings. Given a list of file names, return their longest common suffix, the longest string that every name ends with. Return an empty string if the list is empty or the names share no common ending. For example, ['report_final.txt', 'summary_final.txt', 'final.txt'] share the suffix 'final.txt'.

Examples

common_suffix(names: list[str]) -> str
Example 1
Inputcommon_suffix(["report_final.txt", "summary_final.txt", "final.txt"])
Output"final.txt"