/**
 * Given a matrix of integers and a target integer, 
 * find the number of occurrences of the target integer. 
 *
 * @param matrix a list of lists representing the matrix
 * @param target an integer representing the target value
 * @return count an integer representing the number of occurrences 
 *               of the target value in the matrix
 */
fun countOccurrences(matrix: List<List<Int>>, target: Int): Int {

    var count = 0
    var row = 0
    while (row < matrix.size) {
        var col = 0
        while (col < matrix[row].size) {
            if (matrix[row][col] == target) {
                count++
                // Exiting both while loops
                if (count > 5) {
                    return count
                }
            }
            col++
        }
        row++
    }
    return count
}
/**
 * Given a matrix of integers and a target integer, 
 * find the number of occurrences of the target integer. 
 *
 * @param matrix a list of lists representing the matrix
 * @param target an integer representing the target value
 * @return count an integer representing the number of occurrences 
 *               of the target value in the matrix
 */
fun countOccurrences(matrix: List<List<Int>>, target: Int): Int {
/**
 * Given a matrix of integers and a target integer, 
 * find the number of occurrences of the target integer. 
 *
 * @param matrix a list of lists representing the matrix
 * @param target an integer representing the target value
 * @return count an integer representing the number of occurrences 
 *               of the target value in the matrix
 */
fun countOccurrences(matrix: List<List<Int>>, target: Int): Int {

    var count = 0
    var row = 0
    while (row < matrix.size) {
        var col = 0
        while (col < matrix[row].size) {
            if (matrix[row][col] == target) {
                count++
                // Exiting both while loops
                if (count > 5) {
                    return count
                }
            }
            col++
        }
        row++
    }
    return count
}