Longest Common Ending

Published by Pickle in

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

Examples

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

LongestCommonEnding("potent", "tent") ➞ "tent"

LongestCommonEnding("skyscraper", "carnivore") ➞ ""

Notes

Return an empty string if there exists no common ending.

Watch a quick demo on how Edabit works.