/**
 * Given a list of names and a pattern, return the list of names that contain the pattern.
 *
 * @param names A list of strings representing names.
 * @param pattern A string pattern to search in the names.
 * @return A list of strings containing the given pattern.
 *
 * Example:
 * intersectionOfStrings(listOf("John", "Jennifer", "Joe", "Jonathan"), "ohn") returns ["John", "Jonathan"]
 * intersectionOfStrings(listOf("Lily", "Leo", "Lucy", "Lola"), "o") returns ["Leo", "Lucy", "Lola"]
 */
fun intersectionOfStrings(names: List<String>, pattern: String): List<String> {

    val namesWithPattern = mutableListOf<String>()

    for (name in names) {
        if (pattern in name) {
            namesWithPattern.add(name)
        }
    }

    return namesWithPattern
}
/**
 * Given a list of names and a pattern, return the list of names that contain the pattern.
 *
 * @param names A list of strings representing names.
 * @param pattern A string pattern to search in the names.
 * @return A list of strings containing the given pattern.
 *
 * Example:
 * intersectionOfStrings(listOf("John", "Jennifer", "Joe", "Jonathan"), "ohn") returns ["John", "Jonathan"]
 * intersectionOfStrings(listOf("Lily", "Leo", "Lucy", "Lola"), "o") returns ["Leo", "Lucy", "Lola"]
 */
fun intersectionOfStrings(names: List<String>, pattern: String): List<String> {
/**
 * Given a list of names and a pattern, return the list of names that contain the pattern.
 *
 * @param names A list of strings representing names.
 * @param pattern A string pattern to search in the names.
 * @return A list of strings containing the given pattern.
 *
 * Example:
 * intersectionOfStrings(listOf("John", "Jennifer", "Joe", "Jonathan"), "ohn") returns ["John", "Jonathan"]
 * intersectionOfStrings(listOf("Lily", "Leo", "Lucy", "Lola"), "o") returns ["Leo", "Lucy", "Lola"]
 */
fun intersectionOfStrings(names: List<String>, pattern: String): List<String> {

    val namesWithPattern = mutableListOf<String>()

    for (name in names) {
        if (pattern in name) {
            namesWithPattern.add(name)
        }
    }

    return namesWithPattern
}