/**
 * This function counts the number of occurrences of the target element in the given matrix.
 *
 * @param matrix a 2D list representing the matrix
 * @param target the element whose occurrences need to be counted
 * @return the number of occurrences of the target element in the matrix
 */
fun countOccurrences(matrix: List<List<Int>>, target: Int): Int {

    var count = 0

    for (row in matrix) {  // iterate through each row in the matrix
        for (elem in row) {  // iterate through each element in the row
            // Check if the current element is equal to the target
            if (elem == target) {
                count++
                // Break out of the inner loop if target element is found
                // YOUR CODE HERE
            }
        }
    }

    return count
}
/**
 * This function counts the number of occurrences of the target element in the given matrix.
 *
 * @param matrix a 2D list representing the matrix
 * @param target the element whose occurrences need to be counted
 * @return the number of occurrences of the target element in the matrix
 */
fun countOccurrences(matrix: List<List<Int>>, target: Int): Int {
/**
 * This function counts the number of occurrences of the target element in the given matrix.
 *
 * @param matrix a 2D list representing the matrix
 * @param target the element whose occurrences need to be counted
 * @return the number of occurrences of the target element in the matrix
 */
fun countOccurrences(matrix: List<List<Int>>, target: Int): Int {

    var count = 0

    for (row in matrix) {  // iterate through each row in the matrix
        for (elem in row) {  // iterate through each element in the row
            // Check if the current element is equal to the target
            if (elem == target) {
                count++
                // Break out of the inner loop if target element is found
                // YOUR CODE HERE
            }
        }
    }

    return count
}