#23 - Suffix Search

You are given a list of words. Your task is to implement a suffix search function that efficiently finds all person names in the list that end with a given suffix.

Example 1

Input

names = ["John", "Alison", "Robertson", "Erickson", "Carson", "Addison"]
suffix = "son"

Output

["Robertson", "Erickson", "Carson"]

Example 2

Input

actor_names = ["Rajinikanth", "Kamal Haasan", "Vijay", "Ajith Kumar", "Suriya", "Vijaykanth"]
suffix = "kanth"

Output

["Rajinikanth", "Vijaykanth"]

Last updated