/**
 * This function takes two strings as input and prints the common characters between them.
 */
fun printCommonChars(str1: String, str2: String) {

    // Initialize an empty string to store the common characters
    var commonChars = ""

    // Initialize two pointers at the start of each string
    var i = 0
    var j = 0

    // Perform intersection using while loop and AND operator
    while (i < str1.length && j < str2.length) {
        // Check if the current characters at the pointers are the same
        if (str1[i] == str2[j]) {
            // Append the common character to the commonChars string
            commonChars += str1[i]

            // Increment both pointers to move to the next characters
            i++
            j++
        } else {
            // Increment the pointer for the string with the smaller character
            if (str1[i] < str2[j]) {
                i++
            } else {
                j++
            }
        }
    }

    // Print the common characters found
    println("Common Characters: $commonChars")
}
/**
 * This function takes two strings as input and prints the common characters between them.
 */
fun printCommonChars(str1: String, str2: String) {
/**
 * This function takes two strings as input and prints the common characters between them.
 */
fun printCommonChars(str1: String, str2: String) {

    // Initialize an empty string to store the common characters
    var commonChars = ""

    // Initialize two pointers at the start of each string
    var i = 0
    var j = 0

    // Perform intersection using while loop and AND operator
    while (i < str1.length && j < str2.length) {
        // Check if the current characters at the pointers are the same
        if (str1[i] == str2[j]) {
            // Append the common character to the commonChars string
            commonChars += str1[i]

            // Increment both pointers to move to the next characters
            i++
            j++
        } else {
            // Increment the pointer for the string with the smaller character
            if (str1[i] < str2[j]) {
                i++
            } else {
                j++
            }
        }
    }

    // Print the common characters found
    println("Common Characters: $commonChars")
}