/**
 * This function takes two strings as input and returns a list of common characters between them.
 */
fun findCommonCharacters(string1: String, string2: String): List<Char> {

    val commonChars = mutableListOf<Char>()

    var index1 = 0
    var index2 = 0

    while (index1 < string1.length && index2 < string2.length) {
        when {
            string1[index1] == string2[index2] -> {
                commonChars.add(string1[index1])
                index1++
                index2++
            }
            string1[index1] < string2[index2] -> index1++
            else -> index2++
        }
    }

    return commonChars
}
/**
 * This function takes two strings as input and returns a list of common characters between them.
 */
fun findCommonCharacters(string1: String, string2: String): List<Char> {
/**
 * This function takes two strings as input and returns a list of common characters between them.
 */
fun findCommonCharacters(string1: String, string2: String): List<Char> {

    val commonChars = mutableListOf<Char>()

    var index1 = 0
    var index2 = 0

    while (index1 < string1.length && index2 < string2.length) {
        when {
            string1[index1] == string2[index2] -> {
                commonChars.add(string1[index1])
                index1++
                index2++
            }
            string1[index1] < string2[index2] -> index1++
            else -> index2++
        }
    }

    return commonChars
}