← Back to challenges

Longest Common Ending

PythonHardstringsloops

Instructions

Write a function that returns the longest common ending between two strings.

Examples

longest_common_ending("multiplication", "ration") ➞ "ation"

longest_common_ending("potent", "tent") ➞ "tent"

longest_common_ending("skyscraper", "carnivore") ➞ ""

Notes

Return an empty string if there exists no common ending.

python3
Loading editor…
to run
Walks through the solution with reasoning and edge cases.