/**
 * A method to find frequent words in a dictionary.
 *
 * @param dictionary a dictionary containing words as keys and their frequencies as values
 * @return a list of the most frequent words in the dictionary
 */
fun findFrequentWords(dictionary: Map<String, Int>): List<String> {

    val mostFrequent = mutableListOf<String>()
    var highestFrequency: Int? = null

    for ((word, frequency) in dictionary) {
        if (highestFrequency == null || frequency > highestFrequency) {
            highestFrequency = frequency
            mostFrequent.clear()
            mostFrequent.add(word)
        } else if (frequency == highestFrequency) {
            mostFrequent.add(word)
        }
    }

    return mostFrequent
}

// Example usage
/**
 * A method to find frequent words in a dictionary.
 *
 * @param dictionary a dictionary containing words as keys and their frequencies as values
 * @return a list of the most frequent words in the dictionary
 */
fun findFrequentWords(dictionary: Map<String, Int>): List<String> {
/**
 * A method to find frequent words in a dictionary.
 *
 * @param dictionary a dictionary containing words as keys and their frequencies as values
 * @return a list of the most frequent words in the dictionary
 */
fun findFrequentWords(dictionary: Map<String, Int>): List<String> {

    val mostFrequent = mutableListOf<String>()
    var highestFrequency: Int? = null

    for ((word, frequency) in dictionary) {
        if (highestFrequency == null || frequency > highestFrequency) {
            highestFrequency = frequency
            mostFrequent.clear()
            mostFrequent.add(word)
        } else if (frequency == highestFrequency) {
            mostFrequent.add(word)
        }
    }

    return mostFrequent
}

// Example usage