/**
 * This exercise helps a journalist to count the occurrences of a specific word in a collection of articles.
 *
 * Given a nested list 'articles' that represents a collection of articles, write a function that counts the occurrences of a specific word in the articles and returns the total count.
 *
 * @param articles A nested list of articles where each article is represented as a list of strings.
 * @return The total count of occurrences of the specific word in the articles.
 *
 * Example:
 * articles = listOf(listOf("This", "is", "the", "first", "article"),
 *                   listOf("Here", "is", "the", "second", "article", "with", "word"),
 *                   listOf("In", "the", "third", "article", "there", "is", "another", "word"))
 *
 * countWordOccurrences(articles, "word") -> 2
 */
fun countWordOccurrences(articles: List<List<String>>, targetWord: String): Int {

    var count = 0

    for (article in articles) {
        for (word in article) {
            if (word == targetWord) {
                count++
            }
        }
    }

    return count
}
/**
 * This exercise helps a journalist to count the occurrences of a specific word in a collection of articles.
 *
 * Given a nested list 'articles' that represents a collection of articles, write a function that counts the occurrences of a specific word in the articles and returns the total count.
 *
 * @param articles A nested list of articles where each article is represented as a list of strings.
 * @return The total count of occurrences of the specific word in the articles.
 *
 * Example:
 * articles = listOf(listOf("This", "is", "the", "first", "article"),
 *                   listOf("Here", "is", "the", "second", "article", "with", "word"),
 *                   listOf("In", "the", "third", "article", "there", "is", "another", "word"))
 *
 * countWordOccurrences(articles, "word") -> 2
 */
fun countWordOccurrences(articles: List<List<String>>, targetWord: String): Int {
/**
 * This exercise helps a journalist to count the occurrences of a specific word in a collection of articles.
 *
 * Given a nested list 'articles' that represents a collection of articles, write a function that counts the occurrences of a specific word in the articles and returns the total count.
 *
 * @param articles A nested list of articles where each article is represented as a list of strings.
 * @return The total count of occurrences of the specific word in the articles.
 *
 * Example:
 * articles = listOf(listOf("This", "is", "the", "first", "article"),
 *                   listOf("Here", "is", "the", "second", "article", "with", "word"),
 *                   listOf("In", "the", "third", "article", "there", "is", "another", "word"))
 *
 * countWordOccurrences(articles, "word") -> 2
 */
fun countWordOccurrences(articles: List<List<String>>, targetWord: String): Int {

    var count = 0

    for (article in articles) {
        for (word in article) {
            if (word == targetWord) {
                count++
            }
        }
    }

    return count
}