/**
 * Given two positive integers num1 and num2, return a list of their common digits in ascending order.
 *
 * @param num1 The first positive integer.
 * @param num2 The second positive integer.
 * @return A list containing the common digits of the two numbers in ascending order.
 *
 * Example:
 * getCommonDigits(123456, 253478) => [2, 3, 4, 5]
 *
 * Note:
 * - The solution should not include repeated digits. For example, if num1 has two 2s and num2 has three 2s,
 *   the resulting list should only contain one 2.
 * - The numbers can both have multiple digits.
 */
fun getCommonDigits(num1: Int, num2: Int): List<Int> {

    val commonDigits = mutableListOf<Int>()
    num1.toString().forEach { digit1 ->
        if (digit1.toString() in num2.toString() && digit1.toString().toInt() !in commonDigits) {
            commonDigits.add(digit1.toString().toInt())
        }
    }
    return commonDigits.sorted()
}
/**
 * Given two positive integers num1 and num2, return a list of their common digits in ascending order.
 *
 * @param num1 The first positive integer.
 * @param num2 The second positive integer.
 * @return A list containing the common digits of the two numbers in ascending order.
 *
 * Example:
 * getCommonDigits(123456, 253478) => [2, 3, 4, 5]
 *
 * Note:
 * - The solution should not include repeated digits. For example, if num1 has two 2s and num2 has three 2s,
 *   the resulting list should only contain one 2.
 * - The numbers can both have multiple digits.
 */
fun getCommonDigits(num1: Int, num2: Int): List<Int> {
/**
 * Given two positive integers num1 and num2, return a list of their common digits in ascending order.
 *
 * @param num1 The first positive integer.
 * @param num2 The second positive integer.
 * @return A list containing the common digits of the two numbers in ascending order.
 *
 * Example:
 * getCommonDigits(123456, 253478) => [2, 3, 4, 5]
 *
 * Note:
 * - The solution should not include repeated digits. For example, if num1 has two 2s and num2 has three 2s,
 *   the resulting list should only contain one 2.
 * - The numbers can both have multiple digits.
 */
fun getCommonDigits(num1: Int, num2: Int): List<Int> {

    val commonDigits = mutableListOf<Int>()
    num1.toString().forEach { digit1 ->
        if (digit1.toString() in num2.toString() && digit1.toString().toInt() !in commonDigits) {
            commonDigits.add(digit1.toString().toInt())
        }
    }
    return commonDigits.sorted()
}